ngSticky icon indicating copy to clipboard operation
ngSticky copied to clipboard

initialCSS not getting correct values

Open Floriskoch opened this issue 9 years ago • 2 comments

I'm using ngSticky for two elements. For one of the two element the initialCSS values are not correct. It seems as if the element, which is loaded through a template file via the ui router plugin, is not ready yet when the ngSticky directive is run. When I wrap the initialCSS object in a setTimeout function and return it, this problem doesn't occur.

This feels a bit hacky though. Do you have any suggestions on how to fix this issue properly?

Floriskoch avatar Aug 06 '15 10:08 Floriskoch

It seems as if I figured it out with the help of this article http://buzzdecafe.github.io/2014/03/20/directive-after-dom/.

The element wasn't loaded yet in the DOM apparently, the solution is to wrap the entire content of the link function in a $timeout function with a delay of 100ms.

Any better solutions would still be appreciated!

Floriskoch avatar Aug 06 '15 12:08 Floriskoch

I saw the same thing. As far as I know, your solution of wrapping in a $timeout would be the best fix.

pbtura avatar Oct 20 '15 15:10 pbtura