๐ 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 โ 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'));