Re:Passive event listeners
by Jonas_ba on Wednesday August 16, 2017 @10:55AM
(#15027919)
While passive event listeners are an improvement, they are not a complete solution. It's more like the "least of evils". There is a new set of primitives that is being implemented called IntersectionObserver which solves most of the issues of having to detect when something is in view + they run on a separate thread. So you don't need to do any computations, reading the window size and whatnot magic to detect if an element is inside the window. We are currently using this in prod for our algolia static websites and it has worked very well for the majority of all of our use cases.
https://github.com/WICG/IntersectionObserver/blob/gh-pages/e...
[ Parent
| on HN ]
Why do you need to detect whether something is in the viewport?
For lazyloading stuff like images and ads. Or that technique where you have an infinite list, and the elements that are scrolled off-screen are recycled on the other end.
You can easily scroll so that the intersection observer sentinels are not seen and cause bugs. Disappointing.
Re:Passive event listeners
by eyelidlessness on Wednesday August 16, 2017 @05:04PM
(#15031360)
The linked description provides several use cases.