-
Notifications
You must be signed in to change notification settings - Fork 0
/
vanillajs-scrollspy.min.js
2 lines (2 loc) · 2.94 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()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();var r=function(e){return window.setTimeout(e,1e3/60),e};window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var i=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"easeOutSine";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.menu=t,this.speed=n,this.easing=o}return o(e,[{key:"scrollToY",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=window.scrollY||document.documentElement.scrollTop,o=0,r=Math.max(.1,Math.min(Math.abs(n-t)/this.speed,.8)),i={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)}};!function u(){var a=(o+=1/60)/r,c=i[e.easing](a);a<1?(window.requestAnimFrame(u),window.scrollTo(0,n+(t-n)*c)):window.scrollTo(0,t)}()}},{key:"menuControl",value:function(){var e=void 0,t=void 0,n=void 0,o=this.menu.querySelectorAll('a[href^="#"]'),r=window.scrollY||document.documentElement.scrollTop;for(e=0;e<o.length;e+=1)t=o[e],(n=document.querySelector(t.getAttribute("href"))).offsetTop<=r&&n.offsetTop+n.clientHeight>r?t.classList.add("active"):t.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=void 0,o=this.menu.querySelectorAll('a[href^="#"]');for(n=0;n<o.length;n+=1)o[n].addEventListener("click",t)}},{key:"init",value:function(){var e=this;this.animated(),document.addEventListener("scroll",function(){e.menuControl()})}}]),e}();t.default=i},function(e,t,n){"use strict";e.exports=n(0).default}])});
//# sourceMappingURL=vanillajs-scrollspy.min.js.map