# scrollto-element

> A simple animated scroll to element function.

Latest version **1.0.4** (published 2017-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install scrollto-element
pnpm add scrollto-element
yarn add scrollto-element
bun add scrollto-element
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-06-01 |
| First published | 2017-04-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | blade254353074 |
| Maintainers | blade254353074 |
| Keywords | scrollto, animation, scroll |

## Links

- npm: https://www.npmjs.com/package/scrollto-element
- Repository: https://github.com/blade254353074/scrollto-element
- Homepage: https://github.com/blade254353074/scrollto-element#readme
- Issues: https://github.com/blade254353074/scrollto-element/issues
- npm.io page: https://npm.io/package/scrollto-element

## Dependencies (2)

- [raf](https://npm.io/package/raf.md) ^3.3.2
- [bezier-easing](https://npm.io/package/bezier-easing.md) ^2.0.3

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 1.0.4 (latest) — 2017-06-01
- 1.0.3 — 2017-06-01
- 1.0.2 — 2017-04-02
- 1.0.1 — 2017-04-01
- 1.0.0 — 2017-04-01

## README

# scrollto-element

[![npm version](https://badge.fury.io/js/scrollto-element.svg)](https://badge.fury.io/js/scrollto-element)
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

A simple animated scroll to element function.

* Using requestAnimationFrame
* Only require [bezier-easing](https://github.com/gre/bezier-easing) and [raf](https://github.com/chrisdickinson/raf)

## Install

```bash
npm install scrollto-element --save
// or
yarn add scrollto-element
```

## Usage

```javascript
const scrolltoElement = require('scrollto-element')
// or ES2015+
import scrolltoElement from 'scrollto-element'
```

## Example

```javascript
import scrolltoElement from 'scrollto-element'

scrolltoElement(document.querySelector('#foobar'))
scrolltoElement(element, 300)

// advanced
scrolltoElement({
  element: document.querySelector('#foobar'),
  offset: -100, // default is 0
  bezier: [0.19, 1, 0.22, 1], // default is [0.19, 1, 0.22, 1]
  duration: 3000, // default is 100
  then () {
    console.log('Finished~')
  }
})
```

> offset means scroll to (target element + offset).  
When offset is a positive number, view will scroll through the target.  
When offset is a negative number, view will scroll to near the target.

## See also

* [Easing Function Cheat Sheet](http://easings.net/)

## License

MIT

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