top | item 15027919

(no title)

Jonas_ba | 8 years ago

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

discuss

order

rjbwork|8 years ago

Why do you need to detect whether something is in the viewport?

SimeVidas|8 years ago

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.

eyelidlessness|8 years ago

The linked description provides several use cases.