1.1.4 • Published 6 years ago

scrollyo v1.1.4

Weekly downloads
13
License
ISC
Repository
github
Last release
6 years ago

scrollTo

Simple pure javascript smooth scrolling to element


This script exports two modules, scrollToTop and scrollTo, which can then be imported using the JS import statement currently available in Traceur, Babel, or Rollup.

Install

npm install scrollyo --save

With a "y".

Usage

First import the modules you need:

// Both
import {scrollToTop, scrollTo} from 'scrollyo';
// Just one
import {scrollTo} from 'scrollyo';

You can now use scrollToTop and/or scrollTo:

  • scrollToTop scrolls to the top of the page. Takes one argument for the timeout in miliseconds.

    scrollToTop(700);
  • scrollTo scrolls to any element in the DOM unless the element is already at the scrollTo position. The function takes two arguments: the element and a timeout in miliseconds (both mandatory).

    const myElement = document.querySelector('...');
    scrollTo(myElement, 700);
1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago