Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

on-intersect

2.0.0 • Public • Published

on-intersect stability

npm version build status downloads js-standard-style

Call back when an element intersects with another.

Usage

var onIntersect = require('on-intersect')
var html = require('bel')
 
var el = html`<h1>Yay, we're a heading!</h1>`
 
onIntersect(el, function () {
  console.log('Woot, component is visible!')
})
 
document.body.appendChild(html`
  <main>
    <div style="height: 110vh"></div>
    ${el}
    <div style="height: 110vh"></div>
  </main>
`)

API

stopObserving = onViewport(element, [opts], [onEnter], [onExit])

Call onEnter when an element scrolls into view, and onExit when an element scrolls out of view. opts can be any value passed into the InterSectionObserver constructor.

stopObserving()

Stop the observer.

Installation

$ npm install on-intersect

Further Reading

Authors

License

MIT

install

npm i on-intersect

Downloadsweekly downloads

201

version

2.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability