Closed RedEagle-dh closed 4 months ago
@RedEagle-dh there are two possible solutions to your problem:
By customizing the rootMargin
prop you can specify which part of the screen should be spied on.
https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin
https://www.smashingmagazine.com/2021/07/dynamic-header-intersection-observer/
https://blog.webdevsimplified.com/2022-01/intersection-observer/
Try to add id
attribute to full containers instead of heading tags.
In this case, the library will watch for the height of visible boxes and content with a higher ratio will be marked.
I hope you can find the best configuration for your project. Let me know back with any feedback.
I added rootMargin='-25px 0px 0px 0px'
and changed the threshold from 0
to 1
and now it works!
Thank you very much!
@RedEagle-dh good news, have fun! 🤓
Description
Maybe I did not use the library correctly. but in my case the wrong list item is marked as active. As you will see in the screenshots, I am currently at "security updates", but "bug fixes" is active. Thats not the only case, it happens almost everywhere.
I've added a topOffset of 80, because I have a sticky navbar.
The data I've provided in the code is just some dummy data, but later it will be filled like that.
Expected behavior
The topmost list item should always be marked as active, even with offset.
Screenshots
Environment Information
Code