{"version":3,"sources":["jquery-scrollToTop.es.js"],"names":["global","factory","define","amd","exports","require","mod","jQuery","jqueryScrollToTopEs","this","_jquery","_classCallCheck","instance","Constructor","TypeError","transition","e","end","prefix","supported","el","document","createElement","transitions","WebkitTransition","MozTransition","OTransition","undefined","style","test","window","navigator","userAgent","throttle","func","wait","_this","_now","Date","now","getTime","timeout","context","args","result","previous","later","apply","_len","arguments","length","params","Array","_key","remaining","clearTimeout","setTimeout","_jquery2","obj","__esModule","default","_interopRequireDefault","_createClass","defineProperties","target","props","i","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","DEFAULTS","distance","speed","easing","animation","animationSpeed","mobile","width","trigger","text","skin","namespace","ScrollToTop","options","$doc","extend","classes","animating","show","disabled","useMobile","isShow","_init","value","_build","Math","floor","offset","top","_bindEvents","_toggle","_this2","$trigger","on","checkMobile","addClass","pos","scrollTop","css","margin-top","_insertRule","one","removeClass","stop","animate","appendTo","can","rule","rules"],"mappings":";;;;;;;CAAA,SAAAA,EAAAC,GACA,GAAA,mBAAAC,QAAAA,OAAAC,IACAD,QAAA,UAAAD,QACA,GAAA,oBAAAG,QACAH,EAAAI,QAAA,eACA,CACA,IAAAC,GACAF,YAEAH,EAAAD,EAAAO,QACAP,EAAAQ,oBAAAF,EAAAF,SAVA,CAYAK,KAAA,SAAAC,GACA,aAYA,SAAAC,EAAAC,EAAAC,GACA,KAAAD,aAAAC,GACA,MAAA,IAAAC,UAAA,qCAgDA,SAAAC,IACA,IAAAC,OAAA,EACAC,OAAA,EACAC,EAAA,GACAC,GAAA,EACAC,EAAAC,SAAAC,cAAA,eAEAC,GACAC,iBAAA,sBACAC,cAAA,gBACAC,YAAA,iBACAX,WAAA,iBAGA,IAAAC,KAAAO,EACA,QAAAI,IAAAP,EAAAQ,MAAAZ,GAAA,CACAC,EAAAM,EAAAP,GACAG,GAAA,EACA,MAMA,MAHA,YAAAU,KAAAC,OAAAC,UAAAC,aACAd,EAAA,aAGAA,OAA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,KAAAN,QAAA,qBAEA5E,KAAAkF,KAAAN,QAAA,wBAKAZ,IAAA,cACA2B,MAAA,SAAAwB,GACA,IAAAnH,KAAAoH,QAAApH,KAAAoH,MAAAD,WAEAjG,IAAAlB,KAAAoH,MACApH,KAAAoH,SAEApH,KAAAoH,MAAAD,IAAA,qwBA3RA","file":"jquery-scrollToTop.min.js","sourcesContent":["/**\n* jQuery scrollToTop v0.4.3\n* https://github.com/amazingSurge/jquery-scrollToTop\n*\n* Copyright (c) amazingSurge\n* Released under the LGPL-3.0 license\n*/\nimport $ from 'jquery';\n\nvar DEFAULTS = {\n distance: 200,\n speed: 1000,\n easing: 'linear',\n animation: 'fade', // fade, slide, none\n animationSpeed: 500,\n\n mobile: {\n width: 768,\n distance: 100,\n speed: 1000,\n easing: 'easeInOutElastic',\n animation: 'slide',\n animationSpeed: 200\n },\n\n trigger: null, // Set a custom triggering element. Can be an HTML string or jQuery object\n target: null, // Set a custom target element for scrolling to. Can be element or number\n text: 'Scroll To Top', // Text for element, can contain HTML\n\n skin: null,\n throttle: 250,\n\n namespace: 'scrollToTop'\n};\n\nfunction transition() {\n let e;\n let end;\n let prefix = '';\n let supported = false;\n const el = document.createElement(\"fakeelement\");\n\n const transitions = {\n \"WebkitTransition\": \"webkitTransitionEnd\",\n \"MozTransition\": \"transitionend\",\n \"OTransition\": \"oTransitionend\",\n \"transition\": \"transitionend\"\n };\n\n for (e in transitions) {\n if (el.style[e] !== undefined) {\n end = transitions[e];\n supported = true;\n break;\n }\n }\n if (/(WebKit)/i.test(window.navigator.userAgent)) {\n prefix = '-webkit-';\n }\n return {\n prefix,\n end,\n supported\n };\n}\n\nfunction throttle(func, wait) {\n const _now = Date.now || function() {\n return new Date().getTime();\n };\n\n let timeout;\n let context;\n let args;\n let result;\n let previous = 0;\n let later = function() {\n previous = _now();\n timeout = null;\n result = func.apply(context, args);\n if (!timeout) {\n context = args = null;\n }\n };\n\n return (...params) => {\n /*eslint consistent-this: \"off\"*/\n let now = _now();\n let remaining = wait - (now - previous);\n context = this;\n args = params;\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n previous = now;\n result = func.apply(context, args);\n if (!timeout) {\n context = args = null;\n }\n } else if (!timeout) {\n timeout = setTimeout(later, remaining);\n }\n return result;\n };\n}\n\n/**\n * Plugin constructor\n **/\nclass ScrollToTop {\n constructor(options = {}) {\n this.$doc = $('body');\n this.options = $.extend(true, {}, DEFAULTS, options);\n\n const namespace = this.options.namespace;\n\n if (this.options.skin === null) {\n this.options.skin = 'default';\n }\n\n this.classes = {\n skin: `${namespace}_${this.options.skin}`,\n trigger: namespace,\n animating: `${namespace}_animating`,\n show: `${namespace}_show`\n };\n\n this.disabled = false;\n this.useMobile = false;\n this.isShow = false;\n\n this._init();\n }\n\n _init() {\n this.transition = transition();\n this._build();\n\n if (this.options.target) {\n if (typeof this.options.target === 'number') {\n this.target = this.options.target;\n } else if (typeof this.options.target === 'string') {\n this.target = Math.floor($(this.options.target).offset().top);\n }\n } else {\n this.target = 0;\n }\n\n this._bindEvents();\n\n this._toggle();\n }\n\n _bindEvents() {\n this.$trigger.on('click.scrollToTop', () => {\n this.$doc.trigger('ScrollToTop::jump');\n return false;\n });\n\n // bind events\n this.$doc.on('ScrollToTop::jump', () => {\n if (this.disabled) {\n return;\n }\n\n this.checkMobile();\n\n let speed;\n let easing;\n\n if (this.useMobile) {\n speed = this.options.mobile.speed;\n easing = this.options.mobile.easing;\n } else {\n speed = this.options.speed;\n easing = this.options.easing;\n }\n\n this.$doc.addClass(this.classes.animating);\n\n if (this.transition.supported) {\n const pos = $(window).scrollTop();\n\n this.$doc.css({\n 'margin-top': `${-pos + this.target}px`\n });\n $(window).scrollTop(this.target);\n\n this._insertRule(`.duration_${speed}{${this.transition.prefix}transition-duration: ${speed}ms;}`);\n\n this.$doc.addClass(`easing_${easing} duration_${speed}`).css({\n 'margin-top': ''\n }).one(this.transition.end, () => {\n this.$doc.removeClass(`${this.classes.animating} easing_${easing} duration_${speed}`);\n });\n } else {\n $('html, body').stop(true, false).animate({\n scrollTop: this.target\n }, speed, () => {\n this.$doc.removeClass(this.classes.animating);\n });\n return;\n }\n })\n .on('ScrollToTop::show', () => {\n if (this.isShow) {\n return;\n }\n this.isShow = true;\n\n this.$trigger.addClass(this.classes.show);\n })\n .on('ScrollToTop::hide', () => {\n if (!this.isShow) {\n return;\n }\n this.isShow = false;\n this.$trigger.removeClass(this.classes.show);\n })\n .on('ScrollToTop::disable', () => {\n this.disabled = true;\n this.$doc.trigger('ScrollToTop::hide');\n })\n .on('ScrollToTop::enable', () => {\n this.disabled = false;\n this._toggle();\n });\n\n $(window).on('scroll.ScrollToTop', throttle(() => {\n if (this.disabled) {\n return;\n }\n\n this._toggle();\n }, this.options.throttle));\n\n if (this.options.mobile) {\n $(window).on('resize.ScrollToTop orientationchange.ScrollToTop', throttle(() => {\n if (this.disabled) {\n return;\n }\n\n this.checkMobile();\n }, this.options.throttle));\n }\n }\n\n _build() {\n if (this.options.trigger) {\n this.$trigger = $(this.options.trigger);\n } else {\n this.$trigger = $(`${this.options.text}`).appendTo($('body'));\n }\n\n this._insertRule(`.${this.classes.show}{${this.transition.prefix}animation-duration: ${this.options.animationSpeed}ms;${this.transition.prefix}animation-name: ${this.options.namespace}_${this.options.animation};}`);\n\n if (this.options.mobile) {\n this._insertRule(`@media (max-width: ${this.options.mobile.width}px){.${this.classes.show}{${this.transition.prefix}animation-duration: ${this.options.mobile.animationSpeed}ms !important;${this.transition.prefix}animation-name: ${this.options.namespace}_${this.options.mobile.animation} !important;}}`);\n }\n }\n\n checkMobile() {\n const width = $(window).width();\n\n if (width < this.options.mobile.width) {\n this.useMobile = true;\n } else {\n this.useMobile = false;\n }\n }\n\n can() {\n let distance;\n if (this.useMobile) {\n distance = this.options.mobile.distance;\n } else {\n distance = this.options.distance;\n }\n if ($(window).scrollTop() > distance) {\n return true;\n }\n return false;\n }\n\n _toggle() {\n if (this.can()) {\n this.$doc.trigger('ScrollToTop::show');\n } else {\n this.$doc.trigger('ScrollToTop::hide');\n }\n }\n\n _insertRule(rule) {\n if (this.rules && this.rules[rule]) {\n return;\n } else if (this.rules === undefined) {\n this.rules = {};\n } else {\n this.rules[rule] = true;\n }\n\n if (document.styleSheets && document.styleSheets.length) {\n document.styleSheets[0].insertRule(rule, 0);\n } else {\n const style = document.createElement('style');\n style.innerHTML = rule;\n document.head.appendChild(style);\n }\n }\n\n jump() {\n this.$doc.trigger('ScrollToTop::jump');\n }\n\n disable() {\n this.$doc.trigger('ScrollToTop::disable');\n }\n\n enable() {\n this.$doc.trigger('ScrollToTop::enable');\n }\n\n destroy() {\n this.$trigger.remove();\n this.$doc.data('ScrollToTop', null);\n this.$doc.off('ScrollToTop::enable')\n .off('ScrollToTop::disable')\n .off('ScrollToTop::jump')\n .off('ScrollToTop::show')\n .off('ScrollToTop::hide');\n $(window).off('.ScrollToTop');\n }\n\n static setDefaults(options) {\n $.extend(true, DEFAULTS, $.isPlainObject(options) && options);\n }\n}\n\nvar info = {\n version:'0.4.3'\n};\n\nconst NAMESPACE = 'scrollToTop';\nconst OtherScrollToTop = $.fn.scrollToTop;\n\nconst jQueryScrollToTop = function(options, ...args) {\n if (typeof options === 'string') {\n const method = options;\n\n if (/^_/.test(method)) {\n return false;\n } else if ((/^(get)/.test(method))) {\n const instance = this.first().data(NAMESPACE);\n if (instance && typeof instance[method] === 'function') {\n return instance[method](...args);\n }\n } else {\n return this.each(function() {\n const instance = $.data(this, NAMESPACE);\n if (instance && typeof instance[method] === 'function') {\n instance[method](...args);\n }\n });\n }\n }\n\n return this.each(function() {\n if (!$(this).data(NAMESPACE)) {\n $(this).data(NAMESPACE, new ScrollToTop(options));\n }\n });\n};\n\n$.fn.scrollToTop = jQueryScrollToTop;\n\n$.scrollToTop = $.extend({\n setDefaults: ScrollToTop.setDefaults,\n noConflict: function() {\n $.fn.scrollToTop = OtherScrollToTop;\n return jQueryScrollToTop;\n }\n}, info);\n"]}