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

1 line
757 B
JavaScript

!function(){"use strict";var c;"querySelector"in document&&"addEventListener"in window&&(c=document.querySelector(".generate-back-to-top"),c&&(window.addEventListener("scroll",function(){var e=window.pageYOffset,t=c.getAttribute("data-start-scroll");t<e&&c.classList.add("generate-back-to-top__show"),e<t&&c.classList.remove("generate-back-to-top__show")}),c.addEventListener("click",function(e){var t,o,n,a,r;e.preventDefault(),generatepressBackToTop.smooth?(document.body,t=c.getAttribute("data-scroll-speed")||400,e=window.pageYOffset,o=document.body.offsetTop,n=(o-e)/(t/16),a=function(){window.pageYOffset<=(o||0)&&(clearInterval(r),document.activeElement.blur())},r=setInterval(function(){window.scrollBy(0,n),a()},16)):window.scrollTo(0,0)},!1)))}();