https://github.com/murilobast/scroll-to-target
A simple, light and reliable scroll library
https://github.com/murilobast/scroll-to-target
animated lightweight scroll smooth smooth-scrolling vanilla-javascript
Last synced: 4 months ago
JSON representation
A simple, light and reliable scroll library
- Host: GitHub
- URL: https://github.com/murilobast/scroll-to-target
- Owner: murilobast
- Created: 2017-09-06T19:42:30.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-05T19:50:43.000Z (over 8 years ago)
- Last Synced: 2025-09-24T18:39:39.135Z (8 months ago)
- Topics: animated, lightweight, scroll, smooth, smooth-scrolling, vanilla-javascript
- Language: JavaScript
- Size: 5.86 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# scroll-to-target (scrollToTarget)
Simple, small, reliable and pure javascript scroll library with 0 dependencies.
[](https://nodei.co/npm/scroll-to-target/)
## `Usage`
```js
scrollToTarget(selector, speed, offset)
```
###### name : *string*
> A valid dom selector
>
> *Required*
###### speed : *number*
> Scroll duration in milliseconds
>
> *Optional, defaults to: 300 {ms}*
###### offset : *number*
> Space in pixels between the target element and the window top.
>
> *Optional, defaults to: 0 {pixels}*
## `Example`
```js
scrollToTarget('#valid-dom-element-selector', 500, 80)
```
The code above will scroll the page to the #valid-dom-element-selector with 80px gutter and a duration of 500ms.
## `Compatibility`
IE8+, iOS Safari 3.2+, MS Edge, Chrome 4+, Firefox 3.5+
## `LICENSE`
MIT