-
Notifications
You must be signed in to change notification settings - Fork 167
js-is-stuck does not seem to be added when sticky is supported #42
Comments
Digging in, I think the issue has something to do with "stickyBitStart". Essentially that is smaller then it should be and as a result the js-is-sticky class gets added before the element is actually sticky. |
Dang—no fun!!! @ishields, could you share some info so we can figure this out?
I'm here to help so let me know what I'm missing. ~Thanks again! |
Interesting. So I haven't replicated it yet in code pen because it requires a more advanced use case I think. Basically it seems like the calculation of stickyBitStart changes depending on your scroll position on the page. I put a console.log underneath the line
Then I refreshed the browser a couple of time with different scroll positions. Depending on my scroll position when I refresh, this value changes significantly. It is only correct when I'm scrolled to the very top of the page. Because this value is wrong, the classes are added at the wrong times (before or after the element becomes sticky) I fixed this by using the jquery method offset().top "offset().top". This strategy produces a consistent number thats not based on where you are scrolled on the page. You also need to take into account the offset thats passed in. So this line became
And the last problem seems to be when developing responsive sites. If you change the width of the browser, the start and stop positions of these elements need to change too. As a result I think the calculations of stickyBitStart and stickyBitStop need to be dynamic. So in other words there will likely need to be a method to generate these numbers on the fly rather than set them as constant variables. Thoughts? |
My initial thought is:
If you can make a codepen showing the issue, then I will work with you to make it work how we want. I think/hope with the stickbits |
@ishields, thanks for you notes. I'm going to cancel this issue. Reach out if you have anymore notes/questions/ideas. 🙏 |
Hi @yowainwright, it still doesn't apply the js-is-stuck class in Firefox. I installed stickybits 1.3.5 |
@wernerkrauss 😔 Do you have link you can share? ...Or is the issue visible in demos? 🙏 |
@wernerkrauss I'm not seeing that issue here...? |
Still, both classes are not applied here on our side. |
It seems we have to define |
I'm using the latest version of chrome which supports position: sticky. Unfortunately I'm noticing that js-is-stuck does not seem to be added. Is this a known issue?
I'm defining my sticky element with jquery
The element is sticking correctly but the isStuck just does not work.
The text was updated successfully, but these errors were encountered: