1.0.1 • Published 5 years ago

js-scroll-to v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

js-scroll-to

A pure JS solution for scrolling to a specified element on command.

About

The solution is made purely in JS with cross-framework and cross-browser compatibility in mind.

Parameters

All arguments should be encapsuled in a single object like the following

{ 
  elementId: 'id',
  behaviour: 'smooth',
  axis: 'both'
}

elementId (*): The id of the element to which the view will scroll to.

axis (*) ('x' || 'y' || 'both') (default: 'none'): The axis on which to scroll.

xOffset (optional) (integer): The x axis offset.

yOffset (optional) (integer): The y axis offset.

behavior (optional) ('smooth' || 'auto') (default: 'smooth): The scroll animation behavior.

How to use

Just import it with the new ES6 syntax

import scrollTo from 'js-scroll-to'

or with the good old require

const scrollTo = require('js-scroll-to')

and then use it like any other function

scrollTo({
  elementId: 'some-id',
  yOffset: 10,
  axis: 'y'
})

License

MIT

1.0.1

5 years ago

1.0.0

5 years ago