Skip to content

adrianklimek/smoothscroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smooth Scroll

A lightweight JavaScript package for smooth scroll animation

Installation

Install with npm:

npm install smoothscrolljs

Install with yarn:

yarn add smoothscrolljs

Usage

import smoothScroll from 'smoothscrolljs'

const destinationEl = document.querySelector('.scroll-to')
smoothScroll(destinationEl)

Parameters

Name Description Type Default
destination DOM element to scroll to or a position HTMLElement, Number -
opts - Object -
opts.duration - Number 600
opts.easing function or name of one of predefined easing functions ('linear', 'easeIn', 'easeOut', 'easeInOut') Function, String 'easeInOut'
opts.context an element to apply scroll to HTMLElement window
opts.orientation scroll orientation ('horizontal', 'vertical') String 'vertical'
opts.offset scroll offset in px Number 0
opts.onUpdate a function that is called on every change Function -
opts.onComplete a function that is called on animation end Function -

License

smoothscrolljs is licensed under MIT license.

About

A lightweight JavaScript package for smooth scroll animation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published