ohhskar / smooth-scroll

Pure JS smooth scroll based on osublake's snippet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Smooth Scroll

This repository hosts a snippet that enables smooth scroll on a page by using transforms. This is heavily based on the code by osublake

Usage

Import the function and call it with two parameters. The target and the easing.

import smoothScroll from './smoothScroll';

window.addEventListener('DOMContentLoaded', () => {
  const currentValues = {
    scrollY: 0,
    target: document.querySelector('.smoothScroll__container'),
  };
  smoothScroll(currentValues, 0.05);
});

About

Pure JS smooth scroll based on osublake's snippet


Languages

Language:JavaScript 100.0%