scroll-smooth
Version:
Scroll with _smooth_ gestures
2 lines • 5.09 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("scrollSmooth",[],t):"object"==typeof exports?exports.scrollSmooth=t():e.scrollSmooth=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=n(1);t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.duration,u=void 0===n?500:n,i=t.context,c=void 0===i?window:i,a=t.offset,f=void 0===a?0:a,l=t.ease,s=void 0===l?"easeInOutCubic":l,d=t.callback;if("object"===("undefined"==typeof window?"undefined":o(window))){var p=null!==c.scrollTop&&void 0!==c.scrollTop?c.scrollTop:window.pageYOffset,v=(0,r.calcEndPoint)(e,c,f),y=performance.now(),h=window.requestAnimationFrame;!function t(){var n=performance.now()-y,o=(0,r.setPosition)(p,v,n,u,s);c!==window?c.scrollTop=o:window.scroll(0,o),n>u?"function"==typeof d&&d(e):h(t)}()}},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=t.easeFunctions={linear:function(e){return e},easeInQuad:function(e){return e*e},easeOutQuad:function(e){return e*(2-e)},easeInOutQuad:function(e){return e<.5?2*e*e:(4-2*e)*e-1},easeInCubic:function(e){return e*e*e},easeOutCubic:function(e){return--e*e*e+1},easeInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},easeInQuart:function(e){return e*e*e*e},easeOutQuart:function(e){return 1- --e*e*e*e},easeInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},easeInQuint:function(e){return e*e*e*e*e},easeOutQuint:function(e){return 1+--e*e*e*e*e},easeInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}},r=t.isNumeric=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};t.setPosition=function(e,t,n,r){var u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"easeInOutCubic";return n>r?t:e+(t-e)*o[u](n/r)},t.calcEndPoint=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(r(e))return parseInt(e)+n;var o=t===window||t===document.documentElement?window.pageYOffset:t.scrollTop-t.getBoundingClientRect().top;return("html"===e.nodeName.toLowerCase()?-o:e.getBoundingClientRect().top+o)+n}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),u=o(r),i=n(1),c=n(3),a=o(c),f=n(4),l=o(f);t.default={to:u.default,calcEndPoint:i.calcEndPoint,anchorScroll:a.default,observe:l.default},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=n(0),u=function(e){return e&&e.__esModule?e:{default:e}}(r);t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.query,n=void 0===t?'[href^="#"]:not([href="#"]':t,r=e.match,i=void 0===r?function(e){return document.getElementById(e.hash.substring(1))}:r,c=e.hashChange,a=void 0===c||c,f=e.scrollSmoothConfig,l=document.querySelectorAll(n),s=function(e){e.preventDefault();var t=i(e.target);t&&(a&&history.replaceState(null,null,"#"+t.id),(0,u.default)(t,o({},f)))};Array.from(l).map(function(e){e.addEventListener("click",s,!1)})},e.exports=t.default},function(e,t,n){"use strict";function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.activeClass,n=void 0===t?"active":t,r=e.query,u=void 0===r?'[href^="#"]:not([href="#"]):not([href="#0"])':r,i=e.threshold,c=void 0===i?[.25,.5,.75]:i,a=e.detectType,f=void 0===a?"max":a,l={threshold:c},s=function(e){return e.classList.remove(n)},d=function(e){return e.classList.add(n)},p=function(){document.querySelectorAll("."+n).forEach(s)},v=function(e){p(),d(document.querySelector('a[href="#'+e.id+'"]'))},y=function(e){e.forEach(function(e){e.intersectionRatio>=Math[f].apply(Math,o(c))&&v(e.target)})},h=document.querySelectorAll(u),m=new IntersectionObserver(y,l),b=function(e){var t=document.querySelector("#"+e.hash.slice(1));m.observe(t)};h.forEach(b)},e.exports=t.default}])});
//# sourceMappingURL=index.umd.min.js.map