JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q47910F
  • License MIT

Wrapper of IntersectionObserver

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

npm i intersection-events

Docs

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.