react-waypoint icon indicating copy to clipboard operation
react-waypoint copied to clipboard

Re-implement using IntersectionObserver

Open kesne opened this issue 7 years ago • 7 comments

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 avatar Jun 15 '17 22:06 kesne

@kesne, this is a great idea! Would you be up for making an effort to implement this?

jamesplease avatar Jul 17 '17 06:07 jamesplease

And here is polyfill: https://github.com/WICG/IntersectionObserver/tree/gh-pages/polyfill

stereobooster avatar Aug 11 '17 22:08 stereobooster

@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.

patrick-mcdougle avatar Oct 01 '17 22:10 patrick-mcdougle

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 .

lencioni avatar Oct 01 '17 22:10 lencioni

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?

patrick-mcdougle avatar Oct 02 '17 01:10 patrick-mcdougle

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.

patrick-mcdougle avatar Oct 02 '17 03:10 patrick-mcdougle

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.

emphaticsunshine avatar Feb 16 '20 17:02 emphaticsunshine