ngSticky
ngSticky copied to clipboard
when jquery is on the page, `getInitialDimensions()` returns incorrect values, causing `unStickElement()` to set incorrect values
When jquery is on the page, angular will opt to use it instead of the built in jqlite. jqlite's css()
method returns only the style
attribute's css. jquery's css()
method looks at getComputedStyle()
for the values it returns. Both of them may return the wrong value.
This gist demonstrates how this can be a problem when an element has a css class with left: auto
. View the HTML in browser and scroll up and down a few times to see the bug happen. Jquery will return "0px", and jqlite returns "", but the true value should be "auto".
With jqlite, an empty string is ok because when unStickValues()
is called and an empty string is set for a css value, the property/value pair is ignored and the original css class is applied (in this case, "auto" is used and recomputed).
With jquery, however, unStickElement()
will set the incorrect "0px" value. This causes the next stickElement()
call to use the "0px" value, which puts the sticky element at the far left of the screen.
Here is a PR addressing the issue. Specifically this fixes the left
property, but this bug probably affects other properties.