:eyes: Get notified when a DOM element appear in and out of view.
Get notified when a DOM element appear in and out of view.
Consider using the browser API, Intersection Observer, if you don’t care about IE and if you just need a basic support of in / out of viewport notifications.
Via NPM — npm install @mystroken/intersection
Manually — @mystroken/intersection/dist/intersection.min.js"">https://unpkg.com/@mystroken/intersection/dist/intersection.min.js
Look at the source files for more information.
const options = {};
const o = new Intersection(options);
o.observe(document.querySelectorAll('.in-view'));