# scroll-detector

> detects scroll direction, position and emits events

Latest version **0.7.1** (published 2023-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install scroll-detector
pnpm add scroll-detector
yarn add scroll-detector
bun add scroll-detector
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2023-05-24 |
| First published | 2017-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | yomotsu |
| Maintainers | yomotsu |
| Keywords | scroll |

## Links

- npm: https://www.npmjs.com/package/scroll-detector
- Repository: https://github.com/yomotsu/scroll-detector
- Homepage: https://github.com/yomotsu/scroll-detector#readme
- Issues: https://github.com/yomotsu/scroll-detector/issues
- npm.io page: https://npm.io/package/scroll-detector

## Recent versions

- 0.7.1 (latest) — 2023-05-24
- 0.7.0 — 2023-05-24
- 0.6.1 — 2021-07-04
- 0.6.0 — 2021-07-04
- 0.5.0 — 2021-05-20
- 0.4.0 — 2020-05-11
- 0.3.0 — 2019-12-30
- 0.2.4 — 2019-05-16
- 0.2.3 — 2017-12-01
- 0.2.2 — 2017-11-12
- 0.2.1 — 2017-11-12
- 0.2.0 — 2017-10-24
- 0.1.0 — 2017-10-24
- 0.0.0 — 2017-10-24

## README

# scrollDetector

`scrollDetector` detects scroll event types: scroll derection and whether page-top or page-bottom or middle.

[![Latest NPM release](https://img.shields.io/npm/v/scroll-detector.svg)](https://www.npmjs.com/package/scroll-detector)
![MIT License](https://img.shields.io/npm/l/scroll-detector.svg)

## Example

- [basic](https://yomotsu.github.io/scroll-detector/examples/basic.html)

## Usage

```shell
$ npm install --save scroll-detector
```

then

```javascript
import scrollDetector from 'scroll-detector';

scrollDetector.on( 'scroll', () => {
	console.log( 'scroll' );
} );

scrollDetector.on( 'scroll:up', () => {
	console.log( 'scroll:up' );
} );

scrollDetector.on( 'scroll:down', () => {
	console.log( 'scroll:down' );
} );

scrollDetector.on( 'at:top', () => {
	console.log( 'at:top' );
} );

scrollDetector.on( 'at:bottom', () => {
	console.log( 'at:bottom' );
} );
```

## Other features

- `scrollDetector.isPageTop()` whether at the page top or not.
- `scrollDetector.isPageBottom()` whether at the page bottom or not.
- `scrollDetector.off( eventName, func )` to remove the listener.
- `scrollDetector.getScrollTop()` will return scrollTop amount in pixels.
- `scrollDetector.mute()` to disabled the detector.
- `scrollDetector.unmute()` to re-enable the detector.

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