angular-elastic
angular-elastic copied to clipboard
Added initComputedStyle to avoid deriving layout values from unstyled elements.
In some cases, such as bootstrap modals and popovers, the directive may be linked prior to being inserted into the document. In this state, there are no styles applied to the element. When this occurred, even emitting elastic:adjust did not recalculate the layout values. With this change, the directive is initialized properly without the elastic:adjust, but if cases exist where it is not, emitting elastic:adjust will calculate the layout if styles were not previously available.
This should resolve #31 in a generic way that does not adversely affect other environments or specifically target bootstrap. I noticed the same problem with Bootstrap popovers; the textarea was about 1/2 the height of a line of text since the padding was not yet available from getComputedStyle.
In my case, after applying this fix it was not necessary to call elastic:adjust as the ngModel.$modelValue watcher was the first thing to fire asynchronously after the directive was linked. There is no rendering flash as the layout is still computed before the element is actually made visible.
I urgently need this change... Please merge it in to master branch!!!!
Kind regards
@stalena, it's been quite awhile, I'm still using my fork from this pull request. I just rebased this pull request against the latest master for you: https://github.com/Newstex/angular-elastic/tree/pull-requests/computed-style-check
@idpaterson, many Thanks! It works just fine!
The maintainer may merge it please.
Best regards
@idpaterson do you think your fix is somehow related to this issue #101 ?
The textarea is displayed in a bootstrap modal...
I don't think so but haven't used this in a few years. Feel free to give it try.