Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Arvin iuunhao
Added: Jun 18, 2018 8:16 AM
Views: 5
Tags: js
  1. const scrollToTop = _ => {
  2.   const c = document.documentElement.scrollTop || document.body.scrollTop;
  3.   if (c > 0) {
  4.     window.requestAnimationFrame(scrollToTop);
  5.     window.scrollTo(0, c - c / 8);
  6.   }
  7. };