UNPKG

4.8 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./foundation.core"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery"],e):"object"==typeof exports?exports["foundation.smoothScroll"]=e(require("./foundation.core"),require("jquery")):(t.__FOUNDATION_EXTERNAL__=t.__FOUNDATION_EXTERNAL__||{},t.__FOUNDATION_EXTERNAL__["foundation.smoothScroll"]=e(t.__FOUNDATION_EXTERNAL__["foundation.core"],t.jQuery))}(window,function(o,n){return u={},r.m=i={"./foundation.core":function(t,e){t.exports=o},"./js/entries/plugins/foundation.smoothScroll.js":function(t,e,o){"use strict";o.r(e);var n=o("./foundation.core");o.d(e,"Foundation",function(){return n.Foundation});var r=o("./js/foundation.smoothScroll.js");o.d(e,"SmoothScroll",function(){return r.SmoothScroll}),n.Foundation.plugin(r.SmoothScroll,"SmoothScroll")},"./js/foundation.smoothScroll.js":function(t,e,o){"use strict";o.r(e),o.d(e,"SmoothScroll",function(){return l});var n=o("jquery"),c=o.n(n),r=o("./foundation.core");function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function f(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(t):e}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=function(){function l(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,l),f(this,s(l).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}(l,r["Plugin"]),function(t,e,o){e&&u(t.prototype,e),o&&u(t,o)}(l,[{key:"_setup",value:function(t,e){this.$element=t,this.options=c.a.extend({},l.defaults,this.$element.data(),e),this.className="SmoothScroll",this._init()}},{key:"_init",value:function(){var t=this.$element[0].id||Object(r.GetYoDigits)(6,"smooth-scroll");this.$element.attr({id:t}),this._events()}},{key:"_events",value:function(){this._linkClickListener=this._handleLinkClick.bind(this),this.$element.on("click.zf.smoothScroll",this._linkClickListener),this.$element.on("click.zf.smoothScroll",'a[href^="#"]',this._linkClickListener)}},{key:"_handleLinkClick",value:function(t){var e=this;if(c()(t.currentTarget).is('a[href^="#"]')){var o=t.currentTarget.getAttribute("href");this._inTransition=!0,l.scrollToLoc(o,this.options,function(){e._inTransition=!1}),t.preventDefault()}}},{key:"_destroy",value:function(){this.$element.off("click.zf.smoothScroll",this._linkClickListener),this.$element.off("click.zf.smoothScroll",'a[href^="#"]',this._linkClickListener)}}],[{key:"scrollToLoc",value:function(t,e,o){var n=1<arguments.length&&void 0!==e?e:l.defaults,r=2<arguments.length?o:void 0,i=c()(t);if(!i.length)return!1;var u=Math.round(i.offset().top-n.threshold/2-n.offset);c()("html, body").stop(!0).animate({scrollTop:u},n.animationDuration,n.animationEasing,function(){"function"==typeof r&&r()})}}]),l}();l.defaults={animationDuration:500,animationEasing:"linear",threshold:50,offset:0}},16:function(t,e,o){t.exports=o("./js/entries/plugins/foundation.smoothScroll.js")},jquery:function(t,e){t.exports=n}},r.c=u,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=16);function r(t){if(u[t])return u[t].exports;var e=u[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}var i,u});
2//# sourceMappingURL=foundation.smoothScroll.min.js.map