2.0.0 • Published 8 years ago

vp-notifier v2.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

vp-notifier

A web component that emits event onChange whenever it comes in or goes out of viewport.

#Installation

npm install vp-notifier --save

#Usage

require('vp-notifer')

<x-vp-notifier>
// HTML content
</x-vp-notifier>

document.querySelector('x-vp-notifier')
.addEventListener('onChange', callback)

const callback = x => {
    const rect = x.detail.intersectionRect
    rect.height * rect.width === 0 // component went out of viewport
    rect.height * rect.width > 0   // component came inside viewport
}