Call back when an element intersects with another.
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>
`)
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.
Stop the observer.
$ npm install on-intersect