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 the whole element enters and leaves window.
Less Features, Less Size
ES Modules
npm i intersection-events
import IntersectionEvents from 'intersection-events'
new IntersectionEvents('.js-target', {
onEnter: el => {
// When the whole element enters window
},
onLeave: el => {
// When the whole element leaves window
}
})
If you want to detect enter only once, set isOnce
option to true
.
new IntersectionEvents('.js-target', {
onEnter: el => {
// Do only once
},
isOnce: true
})
CDN
Download (1.7 KB)
<script src="https://unpkg.com/intersection-events"></script>
new IntersectionEvents('.js-target', {
onEnter: () => {}
})
Browsers support
![]() |
![]() |
![]() |
---|---|---|
Edge | last version | last version |
Note
If you need to support browsers that do not support IntersectionObserver
, load the IntersectionObserver
polyfill.
If the IntersectionObserver
polyfill is loaded, browsers support is as follows.
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
IE11, Edge | last version | last version | last version | last version |
If you want more features, please consider other libraries.