# vsbl

> In-viewport detection without event listeners.

Latest version **1.3.3** (published 2019-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install vsbl
pnpm add vsbl
yarn add vsbl
bun add vsbl
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2019-03-12 |
| First published | 2018-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | estrattonbailey |
| Maintainers | estrattonbailey |

## Links

- npm: https://www.npmjs.com/package/vsbl
- Repository: https://github.com/estrattonbailey/vsbl
- Homepage: https://github.com/estrattonbailey/vsbl#readme
- Issues: https://github.com/estrattonbailey/vsbl/issues
- npm.io page: https://npm.io/package/vsbl

## Dependencies (1)

- [srraf](https://npm.io/package/srraf.md) ^3.1.4

## Recent versions

- 1.3.3 (latest) — 2019-03-12
- 1.3.2 — 2019-01-12
- 1.3.1 — 2019-01-10
- 1.3.0 — 2019-01-10
- 1.2.1 — 2018-10-09
- 1.2.0 — 2018-10-09
- 1.1.0 — 2018-09-28
- 1.0.1 — 2018-09-24
- 1.0.0 — 2018-09-22
- 0.0.1 — 2018-09-20

## README

# vsbl
In-viewport detection without event listeners. **440 bytes gzipped.**

## Install
```
npm i vsbl --save
```

# Usage
```javascript
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

```javascript
const listener = vsbl(node, { threshold: 0.25 })(() => console.log('visible'))
```

You can optionally include this threshold as an attribute on the element itself:
```html
<div id='scroll' data-threshold='0.25'></div>
```

## License
MIT License © [Eric Bailey](https://estrattonbailey.com)

---
_Source: https://npm.io/package/vsbl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
