Skip to content

Instantly share code, notes, and snippets.

@froger-me
Created November 19, 2025 02:59
Show Gist options
  • Select an option

  • Save froger-me/749532ef1359dfc7cfbb4a9a3938764c to your computer and use it in GitHub Desktop.

Select an option

Save froger-me/749532ef1359dfc7cfbb4a9a3938764c to your computer and use it in GitHub Desktop.
A smooth scroll to use in devtools console
setTimeout(() => {
const targetScrollY = document.body.scrollHeight - window.innerHeight;
const currentScrollY = window.pageYOffset;
const distance = targetScrollY - currentScrollY;
if (distance <= 0) return; // already at or past the bottom
const speed = 50; // pixels per second — decrease this to make it slower
const duration = (distance / speed) * 1000; // total time in milliseconds
const startTime = performance.now();
function step(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
const scrollTop = currentScrollY + distance * progress;
window.scrollTo(0, scrollTop);
if (progress < 1) {
requestAnimationFrame(step);
}
}
requestAnimationFrame(step);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment