Skip to content

pxlrbt/smoothscroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Smoothscroll

Simple vanilla js library to smoothly scroll to anchors.

Installation

npm install @pxlrbt/smoothscroll

Usage

import Smoothscroll from '@pxlrbt/smoothscroll';
new Smoothscroll({
    speed: 400,
    elementSelector: 'a[href*="#"]',
    useHash: true,
    threshold: function () {
        return document.querySelector('header').offsetHeight;
    }
});
<a href="#section">Scroll to section</a>
...
<section id="section">...</section>