# scroll

> animates the scroll top/left position of an element

Latest version **3.0.1** (published 2019-03-06) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2019-03-06 |
| First published | 2014-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/scroll) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 67 |
| Author | Michael Rhodes |
| Maintainers | michaelrhodes |

## Links

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

## Recent versions

- 3.0.1 (latest) — 2019-03-06
- 3.0.0 — 2019-02-01
- 2.0.3 — 2018-02-19
- 2.0.2 — 2018-02-18
- 2.0.1 — 2017-09-16
- 2.0.0 — 2016-06-07
- 1.0.1 — 2016-06-07
- 1.0.0 — 2015-10-21
- 0.0.3 — 2014-01-06
- 0.0.2 — 2014-01-06
- 0.0.1 — 2014-01-06
- 0.0.0 — 2014-01-06

## README

# scroll
animates the scroll top/left position of an element (in 340 bytes)

[![browser support](https://ci.testling.com/michaelrhodes/scroll.png)](https://ci.testling.com/michaelrhodes/scroll)

note: you may need to polyfill [`requestAnimationFrame`](https://caniuse.com/#feat=requestanimationframe) in older browsers

## install
```sh
npm install scroll
```

## use
```js
var scroll = require('scroll')
var page = require('scroll-doc')()
var ease = require('ease-component')

// Basic usage
scroll.left(page, 200)

// Register a callback
scroll.top(page, 200, function (err, scrollTop) {
  console.log(err)
  // { message: "Scroll cancelled" } or
  // { message: "Element already at target scroll position" } or
  // null

  console.log(scrollTop)
  // => The new scrollTop position of the element
  // This is always returned, even when there’s an `err`.
})

// Specify a custom easing function
scroll.left(page, 200, { ease: ease.inBounce })

// Specify a duration in milliseconds (default: 350) and register a callback.
scroll.left(page, 200, { duration: 1000 }, function (err, scrollLeft) {
})

// Cancel a scroll animation
var options = { duration: 1000 }
var cancel = scroll.top(page, 200, options, function (err, scrollTop) {
  console.log(err.message)
  // => Scroll cancelled

  page.removeEventListener('wheel', cancel)
})

page.addEventListener('wheel', cancel)
```

note: the default easing is `inOutSine` from [component/ease](https://github.com/component/ease).

## obey
[MIT](https://github.com/michaelrhodes/scroll/blob/master/LICENSE)

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