vp-notifier

2.0.0 • Public • Published

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
}

Package Sidebar

Install

npm i vp-notifier

Weekly Downloads

1

Version

2.0.0

License

ISC

Last publish

Collaborators

  • imamudin.naseem
  • minaseem