# @jfm/scrollspy

> Scrollspy using IntersectionObserver

Latest version **0.1.1** (published 2019-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jfm/scrollspy
pnpm add @jfm/scrollspy
yarn add @jfm/scrollspy
bun add @jfm/scrollspy
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-09-12 |
| First published | 2019-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 34.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jiang Fengming |
| Maintainers | jiangfengming |
| Keywords | scrollspy, IntersectionObserver |

## Links

- npm: https://www.npmjs.com/package/@jfm/scrollspy
- Repository: https://github.com/jiangfengming/scrollspy
- Homepage: https://github.com/jiangfengming/scrollspy#readme
- Issues: https://github.com/jiangfengming/scrollspy/issues
- npm.io page: https://npm.io/package/@jfm/scrollspy

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [screenframe3d](https://npm.io/package/screenframe3d.md) — 0 weekly downloads
- [@lyra-mock-api/core](https://npm.io/package/@lyra-mock-api/core.md) — 0 weekly downloads
- [@swarmica/msw-auto-mock](https://npm.io/package/@swarmica/msw-auto-mock.md) — 0 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2019-09-12
- 0.1.0 — 2019-09-12

## README

# scrollspy

Zero dependencies scrollspy library using the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).

[Demo](https://jiangfengming.github.io/scrollspy/example.html)

## Install

```
npm install @jfm/scrollspy
```

## Usage

```js
import scrollspy from '@jfm/scrollspy'
// or
// import { observe, unobserve } from '@jfm/scrollspy'

const el = document.getElementById('section')

function callback(el) {
  console.log('scrolled to', el)
}

scrollspy.observe(el, callback)
```

## APIs

### observe

```js
observe(element, callback)
```

Observe the `element`, call the `callback` when it comes into the viewport.
You can call it multiple times with different callbacks.

### unobserve

```js
unobserve(element, [callback])
```

Unobserve the `element` with `callback`. If `callback` is not defined, remove all the callbacks.

## License
[MIT](LICENSE)

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