0.2.9 • Published 5 years ago

intersection-events v0.2.9

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

intersection-events

Wrapper of IntersectionObserver

You can detect when the whole element enters and leaves window.

Installation

ES Modules

npm

npm i intersection-events
import IntersectionEvents from 'intersection-events'

CDN

unpkg

<script src="https://unpkg.com/intersection-events"></script>

Usage

Docs

new IntersectionEvents('.js-target', {
  onEnter: el => {
    // When the whole element enters window
  },
  onLeave: el => {
    // When the whole element leaves window
  }
})
<div class="js-target"></div>

<!-- Set threshold only for this element -->
<div class="js-target" data-enter-threshold="0.5" data-leave-threshold="0.5"></div>

If you want to detect enter only once, set isOnce option to true.

new IntersectionEvents('.js-target', {
  onEnter: el => {
    // Do only once
  },
  isOnce: true
})

Browsers support

EdgeFirefoxChrome
Edgelast versionlast 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.

IE / EdgeFirefoxChromeSafariiOS Safari
IE11, Edgelast versionlast versionlast versionlast version

If you want more features, please consider other libraries.

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago