You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have custom navbar in my app. Depending on configuration this navbar is either located at top of page, or its below user set header.
Issue
If there's element taking height above affixed one, everything works, however if affix element is at top of page, click events will switch it between affix/affix-top.
This is because if affix isn't affixed and its offsetTop is 0, following line in getState will change it to 'top':
if (offsetTop != null && scrollTop <= offsetTop) return 'top'
Next click event will trigger getState again, this time changing state back off:
The text was updated successfully, but these errors were encountered:
rafalp
changed the title
Affix plugin has problems handling items with offsetTop = 0
v3.3.4: Affix plugin has problems handling items with offsetTop = 0
May 8, 2015
[Closestwbs#16449] Affix plugin w/ items with offsetTop = 0
Not sure how to test this change specifically so if anyone has any suggestions on testing this let me know and I'll add it. I wasn't sure if offsetTop = 0; could be achieved via margin-top: 0; padding-top: 0; or if it had to be done differently
All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4!
Background
I have custom navbar in my app. Depending on configuration this navbar is either located at top of page, or its below user set header.
Issue
If there's element taking height above affixed one, everything works, however if affix element is at top of page, click events will switch it between affix/affix-top.
This is because if affix isn't affixed and its
offsetTop
is 0, following line in getState will change it to 'top':Next click event will trigger getState again, this time changing state back off:
Temporary fix
I have managed to fix this issue, by changing offsetTop to 1 if navbar has no element obove it (and making existing logic work).
Proposed fix
because offsetTop == 0 is edge case,
getState
may check for it via running following check before all other checks:The text was updated successfully, but these errors were encountered: