1.0.2 • Published 8 years ago

scrollto.js v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

scrollto.js

Smooth scroll to a specific position or target element

Examples

import 'scrollto.js';

// Scroll the window object to a specific position
window.scrollToPosition(100, 100);

// Or scroll an element with overflow auto or scroll
let myFoo = document.getElementById('foo');
myFoo.scrollToPosition(300, 10, { duration: 300 });

// Scroll the window to the element with id bar
let myBar = document.getElementById('bar');
window.scrollToElement(myBar);

// Vertically scroll the window to element bar with an offset of 100px
window.scrollToElement(myBar, { horizontal: false, offsetY: 100 });

Scroll options

{
    duration: 500,
    horizontal: true,
    vertical: true,
    offsetX: 0,
    offsetY: 0,
}

Installation

$ npm install scrollto.js --save
1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago