Scroll Progress Indicator Implement

#scrollIndicatior(style="height:6px;background-color:#ffe403;width:0;")
window.onscroll = function () { scrollIndicatior() };

function scrollIndicatior() {
  var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
  var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
  var scrolled = (winScroll / height) * 100;
  vars.scrollIndicatior.style.width = scrolled + "%";
}

https://www.w3schools.com/howto/howto_js_scroll_indicator.asp

Leave a Reply

Your email address will not be published. Required fields are marked *