Smoothly scroll to anchors.
  • JavaScript 100%
Find a file
2020-04-28 12:54:00 +02:00
.github/workflows Initial 2020-04-28 12:48:20 +02:00
src Initial 2020-04-28 12:48:20 +02:00
package.json docs: update readme and package description 2020-04-28 12:54:00 +02:00
README.md docs: update readme and package description 2020-04-28 12:54:00 +02:00

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>