forked from ederssouza/vanillajs-scrollspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvanillajs-scrollspy.min.js
2 lines (2 loc) · 3.25 KB
/
vanillajs-scrollspy.min.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VanillaScrollspy=t():e.VanillaScrollspy=t()}(self,(function(){return(()=>{var e={45:(e,t,n)=>{e.exports=n(579).default},579:(e,t,n)=>{"use strict";function r(e,t,n){return(r=o()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}n.d(t,{default:()=>l});window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60),e};var c=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"easeOutSine";u(this,e),this.$menu=t,this.speed=n,this.easing=r}var t,n;return t=e,(n=[{key:"scrollToY",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=t,r=window.scrollY||document.documentElement.scrollTop,o=Math.max(.1,Math.min(Math.abs(r-n)/this.speed,.8)),i=0,u={easeOutSine:function(e){return Math.sin(e*(Math.PI/2))},easeInOutSine:function(e){return-.5*(Math.cos(Math.PI*e)-1)},easeInOutQuint:function(e){return(e/=.5)<1?.5*Math.pow(e,5):.5*(Math.pow(e-2,5)+2)}},a=function t(){var a=(i+=1/60)/o,c=u[e.easing](a);if(a<1)return window.requestAnimFrame(t),void window.scrollTo(0,r+(n-r)*c);window.scrollTo(0,n)};a()}},{key:"menuControl",value:function(){var e=this.$menu.querySelectorAll('a[href^="#"]'),t=window.scrollY||document.documentElement.scrollTop;Array.from(e).forEach((function(e){var n=document.querySelector(e.getAttribute("href"));return n.offsetTop<=t&&n.offsetTop+n.clientHeight>t?e.classList.add("active"):e.classList.remove("active")}))}},{key:"animated",value:function(){var e=this;function t(t){t.preventDefault();var n=document.querySelector(this.hash);e.scrollToY(n.offsetTop)}var n=this.$menu.querySelectorAll('a[href^="#"]');Array.from(n).forEach((function(e){return e.addEventListener("click",t)}))}},{key:"init",value:function(){var e=this;this.animated(),document.addEventListener("scroll",(function(){return e.menuControl()}))}}])&&a(t.prototype,n),e}();function l(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r(c,t)}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}return n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(45)})()}));
//# sourceMappingURL=vanillajs-scrollspy.min.js.map