All modern browsers now support the IntersectionObserver interface (currently supported for ~88% of web traffic), which allows to track the visibility of page elements more efficiently than by observing scroll events.
We should make use of this new feature, but keep the old implementation as a fallback for incompatible older browsers (or use this polyfill).
All modern browsers now support the IntersectionObserver interface (currently supported for ~88% of web traffic), which allows to track the visibility of page elements more efficiently than by observing scroll events.
We should make use of this new feature, but keep the old implementation as a fallback for incompatible older browsers (or use this polyfill).
References: