laipower/wp-content/themes/generatepress/assets/js/back-to-top.min.js

1 line
712 B
JavaScript
Raw Normal View History

!function(){"use strict";var l;"querySelector"in document&&"addEventListener"in window&&(l=document.querySelector(".generate-back-to-top"),l&&(window.addEventListener("scroll",function(){var t=window.pageYOffset,e=l.getAttribute("data-start-scroll");e<t&&(l.style.opacity="1",l.style.visibility="visible"),t<e&&(l.style.opacity="0",l.style.visibility="hidden")}),l.addEventListener("click",function(t){var e,n,i,o,c,d;t.preventDefault(),document.body,e=l.getAttribute("data-scroll-speed")||400,n=window.pageYOffset,i=document.body.offsetTop,o=(i-n)/(e/16),c=function(){window.pageYOffset<=(i||0)&&(clearInterval(d),document.activeElement.blur())},d=setInterval(function(){window.scrollBy(0,o),c()},16)},!1)))}();