0.1.6 • Published 7 years ago

simple-scroll v0.1.6

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

alt text Simple smooth, animated scroll thingamajiggy written in ES2015.

Basic usage

var simpleScroll = require('simple-scroll');

simpleScroll.element('myId');

Installation

npm install simple-scroll

Features

  • Scroll to an element with an optional offset
  • Scroll to the bottom or the top off the page
  • Scroll a set amount of pixels, viewport height, viewport width or percent
  • Set up automatic usage for internal links
  • Set the scroll duration and the min/max speed

Example usage

var simpleScroll = require('simple-scroll');


//Required element ID as the first parameter,
//optionally an offset as the second parameter animated
//optionally a third parameter for scroll duration
simpleScroll.element('myId', 20, 100);

//the first parameter (amount) is required, the second (duration) is optional
simpleScroll.px(500, 30); //scrolls 500 pixels down in 30 milliseconds
simpleScroll.vh(5); //scrolls 5 viewport height down
simpleScroll.vw(-5); //scrolls 5 viewport width up
simpleScroll.percent(50); //scrolls 50% of the entire page down

//the first parameter (duration) is optional
simpleScroll.toTop(); //scroll to the top
simpleScroll.toBottom(400); //scroll to the bottom in 400 milliseconds
simpleScroll.internalLinks(); //sets up scrolling for internal links


//Set the settings by passing in an object
simpleScroll.setSettings({
    duration: 100,
    minSpeed: 3,
    maxSpeed: 15
})
//These settings are the default settings

Todo

  • Scroll timing functions (e.g. ease, linear, cubic-bezier etc)

If it is of interest, please feel free to contribute on Github

And yes, I am aware that there are better alternatives already out there. This is mostly my own learning.

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago