Package Exports
- intersection-events
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (intersection-events) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
intersection-events
Wrapper of IntersectionObserver
You can detect when elements enter and leave window.
Less Size, Less Features
ES Modules
npm i intersection-events
import IntersectionEvents from 'intersection-events'
new IntersectionEvents('.js-target', {
onEnter: () => {
// When the whole element enters window
},
onLeave: () => {
// When the whole element leaves window
}
})
CDN
Download (1.4 KB)
<script src="https://unpkg.com/intersection-events"></script>
new IntersectionEvents('.js-target', {
onEnter: () => {}
})
Note
If you should support browsers that do not support IntersectionObserver, use IntersectionObserver polyfill.
If you want more features, please consider other libraries.