8000 GitHub - estrattonbailey/vsbl: In-viewport detection without event listeners.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

estrattonbailey/vsbl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

In-viewport detection without event listeners.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0