Model to watch #10
No reviewers
Labels
No labels
bug
dependencies
duplicate
enhancement
help wanted
invalid
investigation
question
release
spike
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: loke/ng2-fittext#10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi guys,
PR - introduced model (property for directive - modelToWatch), when model change -> font size will be recalculated (resolve #8 ).
Example usage :
Where 'book' is property which is "catched" from some backend (so it is loaded after some time ...).
Also created 'minFontSize' parameter with default value 7 (resolve #9 ).
! there is one thing which i do not like very much ...
setTimeout(_ => this.ngAfterViewInit() );
Explanation :
When model is changed -> method 'checkOverflow' is called -> BUT width / height of children / parent has old values (for example, in case of first load everything can be 0 -> because no text has been added to element).
After reading some articles (https://stackoverflow.com/questions/38930183/angular2-expression-has-changed-after-it-was-checked-binding-to-div-width-wi) - it seem like it is nothing special and usage of setTimeout is quite normal.
Please, if you have any ideas, feel free to contribute :-)
Martin
Thanks a lot for your improvements :D
About setTimeout: i don't think it's bad as you used it, for sure it depends on the framework logic but i don't see, for now, alternatives.