1.3.3 • Published 5 years ago

vsbl v1.3.3

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

vsbl

In-viewport detection without event listeners. 440 bytes gzipped.

Install

npm i vsbl --save

Usage

import vsbl from 'vsbl'

const enter = () => {}
const exit = () => {}

const listener = vsbl(document.getElementById('scroll'))(enter, exit)

listener() // destroy

Options

threshold

Trigger visibility sooner or later than usual.

  • Values below 0.5 will be treated as a percentage of the viewport
  • Values of 0.5 and over will be considered pixel values
const listener = vsbl(node, { threshold: 0.25 })(() => console.log('visible'))

You can optionally include this threshold as an attribute on the element itself:

<div id='scroll' data-threshold='0.25'></div>

License

MIT License © Eric Bailey

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago