Skip to content

Instantly share code, notes, and snippets.

View jl-welch's full-sized avatar

James Welch jl-welch

  • Rotherham, South Yorkshire
View GitHub Profile
@jl-welch
jl-welch / smoothScroll.js
Last active July 26, 2019 00:55
Simple example of smooth scrolling using vanilla JS
const duration = 0.06 * 800; // 800ms (60fps)
const from = scrollY;
const to = document.documentElement.scrollHeight;
const change = to - from;
let time = 0;
function ease(change, duration, from, time) {
time /= duration / 2;
if (time < 1) {