react-waypoint
react-waypoint copied to clipboard
Re-implement using IntersectionObserver
It seems like IntersectionObserver
might be a good way to handle this on platforms that support it.
Here's a post outlining how they work: https://developers.google.com/web/updates/2016/04/intersectionobserver
@kesne, this is a great idea! Would you be up for making an effort to implement this?
And here is polyfill: https://github.com/WICG/IntersectionObserver/tree/gh-pages/polyfill
@jmeas Do you have an opinion on whether this library should include a polyfill or if users should "bring their own"? I might start poking around at this for Hacktoberfest.
I'd say it probably depends a little on how big the polyfill is and whether there is a canonical one.
On Sun, Oct 1, 2017, 3:06 PM Patrick McDougle [email protected] wrote:
@jmeas https://github.com/jmeas Do you have an opinion on whether this library should include a polyfill or if users should "bring their own"? I might start poking around at this for Hacktoberfest.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/brigade/react-waypoint/issues/197#issuecomment-333410397, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL7zqDnf49FZYzKtnNxRtDxavGMI4Buks5soAzRgaJpZM4N7zFx .
One other thing that might be effected by this implementation is "rapidScroll". With intersection observer, we no longer have scroll position, just if it is entering or leaving. I guess if you have fireOnRapidScroll set to true, the component will have no choice but to install a scroll listener. But perhaps it could have a more aggressive throttle on it. Thoughts?
See this example that illustrates the problem with IntersectionObserver in the above case.
I've also opened an issue with the W3C to consider this case in the spec, so perhaps something will come of that.
One other thing that might be effected by this implementation is "rapidScroll". With intersection observer, we no longer have scroll position, just if it is entering or leaving. I guess if you have fireOnRapidScroll set to true, the component will have no choice but to install a scroll listener. But perhaps it could have a more aggressive throttle on it. Thoughts?
Can we not provide a disclaimer to the user if they want rapid scroll, it will be registered as scroll event but rest of the use cases can leverage observer. I can help with the implementation as well.