So I have a sticky navbar, and the problem is the instance of intersection observer that is intersecting (entry.isIntersecting
) considers the portion of the sticky menu even though the intersecting item is not shown as it is behind the navbar. I would like to apply an offset so that it only considers the real visible area without the navbar area. Tried playing with rootmargin, threshold and root properties so far. Do note im using scroll-padding-top: 80px;
You could try replacing scroll-padding-top
with scroll-margin-top
because padding in an element is still considered to be a part of that element, whereas margin is a physical separation of elements.
Thank you will try and report back
I’m afraid it made no difference
At this point, I would recommend sharing a live sample of your code so that we can better see what you’re trying to accomplish and what you have.
You can host it on something like Codepen, JSFiddle, Replit.com, or any other service where we can see the code and run it.
I believe you should be able to use the rootMargin
option to account for the header height. But we do not know what you have tried and I guess it might also depend on what you are actually using the observer for. As said, without a live example it is kind of hard to help (if we can).
Example using rootMargin
Ok, question: is generally useful or good idea to post a live page for which the code is in use? Would it be good enough?
It would be better if it was an online editor. But any code is better than no code.
It will take me a bit to release the page above mentioned, once I do I will post it here.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.