# @ultraq/smooth-scroll-to

> Smooth-scroll to a page element

Latest version **0.2.0** (published 2018-04-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ultraq/smooth-scroll-to
pnpm add @ultraq/smooth-scroll-to
yarn add @ultraq/smooth-scroll-to
bun add @ultraq/smooth-scroll-to
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2018-04-05 |
| First published | 2017-12-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 25.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Emanuel Rabina |
| Maintainers | ultraq |
| Keywords | smooth, scroll |

## Links

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

## Dependencies (3)

- [bezier-easing](https://npm.io/package/bezier-easing.md) ^2.0.3
- [@ultraq/transition](https://npm.io/package/@ultraq/transition.md) ^1.1.0
- [dumb-query-selector](https://npm.io/package/dumb-query-selector.md) ^3.2.0

## Recent versions

- 0.2.0 (latest) — 2018-04-05
- 0.1.0 — 2017-12-02

## README

smooth-scroll-to
================

[![npm](https://img.shields.io/npm/v/@ultraq/smooth-scroll-to.svg?maxAge=3600)](https://www.npmjs.com/package/@ultraq/smooth-scroll-to)
[![License](https://img.shields.io/github/license/ultraq/smooth-scroll-to.svg?maxAge=2592000)](https://github.com/ultraq/smooth-scroll-to/blob/master/LICENSE.txt)

Smooth-scroll to a page element.

Ideally, one would use only CSS and apply `scroll-behaviour: smooth;` to the
area that is being scrolled, rendering this library redundant.  As of writing
however, Chrome's implementation doesn't scroll in a fixed amount of time,
instead accelerating to a top speed, maintaining that speed, then deccelerating
as the target approaches.  This is less than ideal on long documents where the
scrolling can take **extremely** long :(  Hence, this JS solution.


Installation
------------

If importing into your own project with NPM:

```
npm install @ultraq/smooth-scroll-to --save
```

Or using as a standalone library:

```html
<script src="https://unpkg.com/@ultraq/smooth-scroll-to/dist/smooth-scroll-to.min.js"></script>
```


Usage
-----

This project exports a single function, `smoothScrollTo`.  If installed via NPM,
you can use this function by `require`ing/`import`ing it into your code.  If
using the standalone browser bundle either through the unpkg CDN or linking to
the `dist/smoothScrollTo.min.js` file, then this function is available globally.

```javascript
import smoothScrollTo from 'smooth-scroll-to';

smoothScrollTo('body', '#error-banner');
```

### smoothScrollTo(containerSelector, targetSelector)

 - **containerSelector**: a CSS selector for picking out the scrolling container
   that has the target element to scroll into view
 - **targetSelector**: a CSS selector for picking out the element to scroll to.

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