intersection-events
Wrapper of IntersectionObserver
You can detect when elements enter and leave window.
Less Size, Less Features
ES Modules
npm
npm i intersection-events
Docs
import IntersectionEvents from 'intersection-events'
new IntersectionEvents('.js-target', {
onEnter: () => {
},
onLeave: () => {
}
})
CDN
Download (1.4 KB)
<script src="https://unpkg.com/intersection-events"></script>
new IntersectionEvents('.js-target', {
onEnter: () => {}
})
If you should support browsers that do not support IntersectionObserver, use IntersectionObserver polyfill.
If you want more features, please consider other libraries.