civiccc / react-waypoint

A React component to execute a function whenever you scroll to an element.
MIT License
4.08k stars 208 forks source link

waypoint triggers unintentionally when page is scrolled by setting document.body.scrollTop #311

Open zhaotongpan opened 5 years ago

zhaotongpan commented 5 years ago

Hey guys! Thank you so much for this great tool! Not sure if the title is clear enough. The problem i'm having right now is I have a few waypoint components in the page. And there's another interaction that if user clicks a button/link, the page will automatically scroll to a certain position by setting document.body.scrollTop. When the page scrolls some waypoint components would be passed, which will trigger the onEnter events of them unintentionally. Is there anyway to avoid that? I have some events tracking binded to those components but I don't want to track cases like these.

trotzig commented 5 years ago

Try setting the fireOnRapidScroll prop to false.

kenianbei commented 4 years ago

That didn't work for me. I ended up implementing an async scrollTo to track when the window was scrolling.