sweet-scroll
Advanced tools
Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "sweet-scroll", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Modern and the sweet smooth scroll library.", | ||
@@ -5,0 +5,0 @@ "main": "sweet-scroll.js", |
@@ -8,3 +8,3 @@ /*! | ||
* @license MIT | ||
* @version 0.2.4 | ||
* @version 0.2.5 | ||
*/ | ||
@@ -95,3 +95,3 @@ (function (global, factory) { | ||
function hasProp(obj, key) { | ||
return obj && Object.prototype.hasOwnProperty.call(obj, key); | ||
return obj && obj.hasOwnProperty(key); | ||
} | ||
@@ -159,7 +159,13 @@ | ||
function addEvent(el, event, listener) { | ||
el.addEventListener(event, listener, false); | ||
var events = event.split(","); | ||
events.forEach(function (eventName) { | ||
el.addEventListener(eventName.trim(), listener, false); | ||
}); | ||
} | ||
function removeEvent(el, event, listener) { | ||
el.removeEventListener(event, listener, false); | ||
var events = event.split(","); | ||
events.forEach(function (eventName) { | ||
el.removeEventListener(eventName.trim(), listener, false); | ||
}); | ||
} | ||
@@ -287,9 +293,10 @@ | ||
var mathCos = Math.cos; | ||
var mathSin = Math.sin; | ||
var mathPow = Math.pow; | ||
var mathAbs = Math.abs; | ||
var mathSqrt = Math.sqrt; | ||
var mathAsin = Math.asin; | ||
var PI = Math.PI; | ||
var math = Math; | ||
var mathCos = math.cos; | ||
var mathSin = math.sin; | ||
var mathPow = math.pow; | ||
var mathAbs = math.abs; | ||
var mathSqrt = math.sqrt; | ||
var mathAsin = math.asin; | ||
var PI = math.PI; | ||
@@ -300,11 +307,11 @@ function linear(p) { | ||
function easeInQuad(x, t, b, c, d) { | ||
function InQuad(x, t, b, c, d) { | ||
return c * (t /= d) * t + b; | ||
} | ||
function easeOutQuad(x, t, b, c, d) { | ||
function OutQuad(x, t, b, c, d) { | ||
return -c * (t /= d) * (t - 2) + b; | ||
} | ||
function easeInOutQuad(x, t, b, c, d) { | ||
function InOutQuad(x, t, b, c, d) { | ||
if ((t /= d / 2) < 1) { | ||
@@ -316,11 +323,11 @@ return c / 2 * t * t + b; | ||
function easeInCubic(x, t, b, c, d) { | ||
function InCubic(x, t, b, c, d) { | ||
return c * (t /= d) * t * t + b; | ||
} | ||
function easeOutCubic(x, t, b, c, d) { | ||
function OutCubic(x, t, b, c, d) { | ||
return c * ((t = t / d - 1) * t * t + 1) + b; | ||
} | ||
function easeInOutCubic(x, t, b, c, d) { | ||
function InOutCubic(x, t, b, c, d) { | ||
if ((t /= d / 2) < 1) { | ||
@@ -332,11 +339,11 @@ return c / 2 * t * t * t + b; | ||
function easeInQuart(x, t, b, c, d) { | ||
function InQuart(x, t, b, c, d) { | ||
return c * (t /= d) * t * t * t + b; | ||
} | ||
function easeOutQuart(x, t, b, c, d) { | ||
function OutQuart(x, t, b, c, d) { | ||
return -c * ((t = t / d - 1) * t * t * t - 1) + b; | ||
} | ||
function easeInOutQuart(x, t, b, c, d) { | ||
function InOutQuart(x, t, b, c, d) { | ||
if ((t /= d / 2) < 1) { | ||
@@ -348,11 +355,11 @@ return c / 2 * t * t * t * t + b; | ||
function easeInQuint(x, t, b, c, d) { | ||
function InQuint(x, t, b, c, d) { | ||
return c * (t /= d) * t * t * t * t + b; | ||
} | ||
function easeOutQuint(x, t, b, c, d) { | ||
function OutQuint(x, t, b, c, d) { | ||
return c * ((t = t / d - 1) * t * t * t * t + 1) + b; | ||
} | ||
function easeInOutQuint(x, t, b, c, d) { | ||
function InOutQuint(x, t, b, c, d) { | ||
if ((t /= d / 2) < 1) { | ||
@@ -364,23 +371,23 @@ return c / 2 * t * t * t * t * t + b; | ||
function easeInSine(x, t, b, c, d) { | ||
function InSine(x, t, b, c, d) { | ||
return -c * mathCos(t / d * (PI / 2)) + c + b; | ||
} | ||
function easeOutSine(x, t, b, c, d) { | ||
function OutSine(x, t, b, c, d) { | ||
return c * mathSin(t / d * (PI / 2)) + b; | ||
} | ||
function easeInOutSine(x, t, b, c, d) { | ||
function InOutSine(x, t, b, c, d) { | ||
return -c / 2 * (mathCos(PI * t / d) - 1) + b; | ||
} | ||
function easeInExpo(x, t, b, c, d) { | ||
function InExpo(x, t, b, c, d) { | ||
return t === 0 ? b : c * mathPow(2, 10 * (t / d - 1)) + b; | ||
} | ||
function easeOutExpo(x, t, b, c, d) { | ||
function OutExpo(x, t, b, c, d) { | ||
return t === d ? b + c : c * (-mathPow(2, -10 * t / d) + 1) + b; | ||
} | ||
function easeInOutExpo(x, t, b, c, d) { | ||
function InOutExpo(x, t, b, c, d) { | ||
if (t === 0) return b; | ||
@@ -392,11 +399,11 @@ if (t === d) return b + c; | ||
function easeInCirc(x, t, b, c, d) { | ||
function InCirc(x, t, b, c, d) { | ||
return -c * (mathSqrt(1 - (t /= d) * t) - 1) + b; | ||
} | ||
function easeOutCirc(x, t, b, c, d) { | ||
function OutCirc(x, t, b, c, d) { | ||
return c * mathSqrt(1 - (t = t / d - 1) * t) + b; | ||
} | ||
function easeInOutCirc(x, t, b, c, d) { | ||
function InOutCirc(x, t, b, c, d) { | ||
if ((t /= d / 2) < 1) { | ||
@@ -408,3 +415,3 @@ return -c / 2 * (mathSqrt(1 - t * t) - 1) + b; | ||
function easeInElastic(x, t, b, c, d) { | ||
function InElastic(x, t, b, c, d) { | ||
var s = 1.70158, | ||
@@ -425,3 +432,3 @@ p = 0, | ||
function easeOutElastic(x, t, b, c, d) { | ||
function OutElastic(x, t, b, c, d) { | ||
var s = 1.70158, | ||
@@ -442,3 +449,3 @@ p = 0, | ||
function easeInOutElastic(x, t, b, c, d) { | ||
function InOutElastic(x, t, b, c, d) { | ||
var s = 1.70158, | ||
@@ -462,3 +469,3 @@ p = 0, | ||
function easeInBack(x, t, b, c, d) { | ||
function InBack(x, t, b, c, d) { | ||
var s = arguments.length <= 5 || arguments[5] === undefined ? 1.70158 : arguments[5]; | ||
@@ -469,3 +476,3 @@ | ||
function easeOutBack(x, t, b, c, d) { | ||
function OutBack(x, t, b, c, d) { | ||
var s = arguments.length <= 5 || arguments[5] === undefined ? 1.70158 : arguments[5]; | ||
@@ -476,3 +483,3 @@ | ||
function easeInOutBack(x, t, b, c, d) { | ||
function InOutBack(x, t, b, c, d) { | ||
var s = arguments.length <= 5 || arguments[5] === undefined ? 1.70158 : arguments[5]; | ||
@@ -486,7 +493,7 @@ | ||
function easeInBounce(x, t, b, c, d) { | ||
return c - easeOutBounce(x, d - t, 0, c, d) + b; | ||
function InBounce(x, t, b, c, d) { | ||
return c - OutBounce(x, d - t, 0, c, d) + b; | ||
} | ||
function easeOutBounce(x, t, b, c, d) { | ||
function OutBounce(x, t, b, c, d) { | ||
if ((t /= d) < 1 / 2.75) { | ||
@@ -503,7 +510,7 @@ return c * (7.5625 * t * t) + b; | ||
function easeInOutBounce(x, t, b, c, d) { | ||
function InOutBounce(x, t, b, c, d) { | ||
if (t < d / 2) { | ||
return easeInBounce(x, t * 2, 0, c, d) * .5 + b; | ||
return InBounce(x, t * 2, 0, c, d) * .5 + b; | ||
} | ||
return easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b; | ||
return OutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b; | ||
} | ||
@@ -513,32 +520,32 @@ | ||
linear: linear, | ||
easeInQuad: easeInQuad, | ||
easeOutQuad: easeOutQuad, | ||
easeInOutQuad: easeInOutQuad, | ||
easeInCubic: easeInCubic, | ||
easeOutCubic: easeOutCubic, | ||
easeInOutCubic: easeInOutCubic, | ||
easeInQuart: easeInQuart, | ||
easeOutQuart: easeOutQuart, | ||
easeInOutQuart: easeInOutQuart, | ||
easeInQuint: easeInQuint, | ||
easeOutQuint: easeOutQuint, | ||
easeInOutQuint: easeInOutQuint, | ||
easeInSine: easeInSine, | ||
easeOutSine: easeOutSine, | ||
easeInOutSine: easeInOutSine, | ||
easeInExpo: easeInExpo, | ||
easeOutExpo: easeOutExpo, | ||
easeInOutExpo: easeInOutExpo, | ||
easeInCirc: easeInCirc, | ||
easeOutCirc: easeOutCirc, | ||
easeInOutCirc: easeInOutCirc, | ||
easeInElastic: easeInElastic, | ||
easeOutElastic: easeOutElastic, | ||
easeInOutElastic: easeInOutElastic, | ||
easeInBack: easeInBack, | ||
easeOutBack: easeOutBack, | ||
easeInOutBack: easeInOutBack, | ||
easeInBounce: easeInBounce, | ||
easeOutBounce: easeOutBounce, | ||
easeInOutBounce: easeInOutBounce | ||
InQuad: InQuad, | ||
OutQuad: OutQuad, | ||
InOutQuad: InOutQuad, | ||
InCubic: InCubic, | ||
OutCubic: OutCubic, | ||
InOutCubic: InOutCubic, | ||
InQuart: InQuart, | ||
OutQuart: OutQuart, | ||
InOutQuart: InOutQuart, | ||
InQuint: InQuint, | ||
OutQuint: OutQuint, | ||
InOutQuint: InOutQuint, | ||
InSine: InSine, | ||
OutSine: OutSine, | ||
InOutSine: InOutSine, | ||
InExpo: InExpo, | ||
OutExpo: OutExpo, | ||
InOutExpo: InOutExpo, | ||
InCirc: InCirc, | ||
OutCirc: OutCirc, | ||
InOutCirc: InOutCirc, | ||
InElastic: InElastic, | ||
OutElastic: OutElastic, | ||
InOutElastic: InOutElastic, | ||
InBack: InBack, | ||
OutBack: OutBack, | ||
InOutBack: InOutBack, | ||
InBounce: InBounce, | ||
OutBounce: OutBounce, | ||
InOutBounce: InOutBounce | ||
}); | ||
@@ -567,3 +574,3 @@ | ||
this.delay = delay; | ||
this.easing = easing; | ||
this.easing = easing.replace("ease", ""); | ||
this.callback = callback; | ||
@@ -649,2 +656,3 @@ this.progress = true; | ||
var WHEEL_EVENT = "onwheel" in doc ? "wheel" : "onmousewheel" in doc ? "mousewheel" : "DOMMouseScroll"; | ||
var CONTAINER_STOP_EVENTS = WHEEL_EVENT + ", touchstart, touchmove"; | ||
@@ -1068,5 +1076,3 @@ var SweetScroll = function () { | ||
this._stopScrollListener = this.handleStopScroll.bind(this); | ||
addEvent(container, WHEEL_EVENT, this._stopScrollListener); | ||
addEvent(container, "touchstart", this._stopScrollListener); | ||
addEvent(container, "touchmove", this._stopScrollListener); | ||
addEvent(container, CONTAINER_STOP_EVENTS, this._stopScrollListener); | ||
} | ||
@@ -1086,5 +1092,3 @@ | ||
if (!container || !this._stopScrollListener) return; | ||
removeEvent(container, WHEEL_EVENT, this._stopScrollListener); | ||
removeEvent(container, "touchstart", this._stopScrollListener); | ||
removeEvent(container, "touchmove", this._stopScrollListener); | ||
removeEvent(container, CONTAINER_STOP_EVENTS, this._stopScrollListener); | ||
this._stopScrollListener = null; | ||
@@ -1091,0 +1095,0 @@ } |
@@ -8,4 +8,4 @@ /*! | ||
* @license MIT | ||
* @version 0.2.4 | ||
* @version 0.2.5 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.SweetScroll=e()}(this,function(){"use strict";function t(t){return null==t?t+"":"object"===("undefined"==typeof t?"undefined":et["typeof"](t))||"function"==typeof t?it[Object.prototype.toString.call(t)]||"object":"undefined"==typeof t?"undefined":et["typeof"](t)}function e(t){return Array.isArray(t)}function n(t){var e=null==t?null:t.length;return i(e)&&e>=0&&nt>=e}function r(n){return!e(n)&&"object"===t(n)}function i(e){return"number"===t(e)}function o(e){return"string"===t(e)}function l(e){return"function"===t(e)}function a(t){return!e(t)&&t-parseFloat(t)+1>=0}function u(t,e){return t&&Object.prototype.hasOwnProperty.call(t,e)}function s(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];return c(n,function(e){c(e,function(e,n){t[n]=e})}),t}function c(t,e,i){if(null==t)return t;if(i=i||t,r(t)){for(var o in t)if(u(t,o)&&e.call(i,t[o],o)===!1)break}else if(n(t)){var l=void 0,a=t.length;for(l=0;a>l&&e.call(i,t[l],l)!==!1;l++);}return t}function h(t){return t.replace(/\s*/g,"")||""}function f(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(t)return(null==e?document:e).querySelector(t)}function p(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(t)return(null==e?document:e).querySelectorAll(t)}function g(t,e){for(var n=(t.document||t.ownerDocument).querySelectorAll(e),r=n.length;--r>=0&&n.item(r)!==t;);return r>-1}function d(t,e,n){t.addEventListener(e,n,!1)}function m(t,e,n){t.removeEventListener(e,n,!1)}function v(t){var e=document;return t===e.documentElement||t===e.body}function y(t){for(var e=arguments.length<=1||void 0===arguments[1]?"y":arguments[1],n=arguments.length<=2||void 0===arguments[2]?!0:arguments[2],r=ot[e],i=t instanceof HTMLElement?[t]:p(t),o=[],l=document.createElement("div"),a=0;a<i.length;a++){var u=i[a];if(u[r]>0?o.push(u):(l.style.width=u.clientWidth+1+"px",l.style.height=u.clientHeight+1+"px",u.appendChild(l),u[r]=1,u[r]>0&&o.push(u),u[r]=0,u.removeChild(l)),!n&&o.length>0)break}return o}function S(t,e){var n=y(t,e,!1);return n.length>=1?n[0]:void 0}function C(t){return null!=t&&t===t.window?t:9===t.nodeType&&t.defaultView}function b(t){var e=arguments.length<=1||void 0===arguments[1]?"y":arguments[1],n=ot[e],r=lt[e],i=C(t);return i?i[r]:t[n]}function k(t,e){var n=arguments.length<=2||void 0===arguments[2]?"y":arguments[2],r=ot[n],i=C(t),o="y"===n;i?i.scrollTo(o?i.pageXOffset:e,o?e:i.pageYOffset):t[r]=e}function w(t){var e=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(!t||t&&!t.getClientRects().length)return{top:0,left:0};var n=t.getBoundingClientRect();if(n.width||n.height){var r={},i=void 0;if(null==e||v(e))i=t.ownerDocument.documentElement,r.top=window.pageYOffset,r.left=window.pageXOffset;else{i=e;var o=i.getBoundingClientRect();r.top=-1*o.top+i.scrollTop,r.left=-1*o.left+i.scrollLeft}return{top:n.top+r.top-i.clientTop,left:n.left+r.left-i.clientLeft}}return n}function O(t){return t}function _(t,e,n,r,i){return r*(e/=i)*e+n}function L(t,e,n,r,i){return-r*(e/=i)*(e-2)+n}function I(t,e,n,r,i){return(e/=i/2)<1?r/2*e*e+n:-r/2*(--e*(e-2)-1)+n}function x(t,e,n,r,i){return r*(e/=i)*e*e+n}function M(t,e,n,r,i){return r*((e=e/i-1)*e*e+1)+n}function T(t,e,n,r,i){return(e/=i/2)<1?r/2*e*e*e+n:r/2*((e-=2)*e*e+2)+n}function E(t,e,n,r,i){return r*(e/=i)*e*e*e+n}function A(t,e,n,r,i){return-r*((e=e/i-1)*e*e*e-1)+n}function j(t,e,n,r,i){return(e/=i/2)<1?r/2*e*e*e*e+n:-r/2*((e-=2)*e*e*e-2)+n}function Q(t,e,n,r,i){return r*(e/=i)*e*e*e*e+n}function z(t,e,n,r,i){return r*((e=e/i-1)*e*e*e*e+1)+n}function B(t,e,n,r,i){return(e/=i/2)<1?r/2*e*e*e*e*e+n:r/2*((e-=2)*e*e*e*e+2)+n}function D(t,e,n,r,i){return-r*st(e/i*(dt/2))+r+n}function H(t,e,n,r,i){return r*ct(e/i*(dt/2))+n}function q(t,e,n,r,i){return-r/2*(st(dt*e/i)-1)+n}function P(t,e,n,r,i){return 0===e?n:r*ht(2,10*(e/i-1))+n}function F(t,e,n,r,i){return e===i?n+r:r*(-ht(2,-10*e/i)+1)+n}function R(t,e,n,r,i){return 0===e?n:e===i?n+r:(e/=i/2)<1?r/2*ht(2,10*(e-1))+n:r/2*(-ht(2,-10*--e)+2)+n}function W(t,e,n,r,i){return-r*(pt(1-(e/=i)*e)-1)+n}function $(t,e,n,r,i){return r*pt(1-(e=e/i-1)*e)+n}function N(t,e,n,r,i){return(e/=i/2)<1?-r/2*(pt(1-e*e)-1)+n:r/2*(pt(1-(e-=2)*e)+1)+n}function X(t,e,n,r,i){var o=1.70158,l=0,a=r;return 0===e?n:1===(e/=i)?n+r:(l||(l=.3*i),a<ft(r)?(a=r,o=l/4):o=l/(2*dt)*gt(r/a),-(a*ht(2,10*(e-=1))*ct((e*i-o)*(2*dt)/l))+n)}function Y(t,e,n,r,i){var o=1.70158,l=0,a=r;return 0===e?n:1===(e/=i)?n+r:(l||(l=.3*i),a<ft(r)?(a=r,o=l/4):o=l/(2*dt)*gt(r/a),a*ht(2,-10*e)*ct((e*i-o)*(2*dt)/l)+r+n)}function J(t,e,n,r,i){var o=1.70158,l=0,a=r;return 0===e?n:2===(e/=i/2)?n+r:(l||(l=i*(.3*1.5)),a<ft(r)?(a=r,o=l/4):o=l/(2*dt)*gt(r/a),1>e?-.5*(a*ht(2,10*(e-=1))*ct((e*i-o)*(2*dt)/l))+n:a*ht(2,-10*(e-=1))*ct((e*i-o)*(2*dt)/l)*.5+r+n)}function V(t,e,n,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return r*(e/=i)*e*((o+1)*e-o)+n}function G(t,e,n,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return r*((e=e/i-1)*e*((o+1)*e+o)+1)+n}function K(t,e,n,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return(e/=i/2)<1?r/2*(e*e*(((o*=1.525)+1)*e-o))+n:r/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+n}function U(t,e,n,r,i){return r-Z(t,i-e,0,r,i)+n}function Z(t,e,n,r,i){return(e/=i)<1/2.75?r*(7.5625*e*e)+n:2/2.75>e?r*(7.5625*(e-=1.5/2.75)*e+.75)+n:2.5/2.75>e?r*(7.5625*(e-=2.25/2.75)*e+.9375)+n:r*(7.5625*(e-=2.625/2.75)*e+.984375)+n}function tt(t,e,n,r,i){return i/2>e?.5*U(t,2*e,0,r,i)+n:.5*Z(t,2*e-i,0,r,i)+.5*r+n}var et={};et["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},et.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},et.createClass=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var nt=Math.pow(2,53)-1,rt=["Boolean","Number","String","Function","Array","Object"],it={};rt.forEach(function(t){it["[object "+t+"]"]=t.toLowerCase()});var ot={y:"scrollTop",x:"scrollLeft"},lt={y:"pageYOffset",x:"pageXOffset"},at=0,ut=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){var e=Date.now(),n=Math.max(0,16-(e-at)),r=window.setTimeout(function(){t(e+n)},n);return at=e+n,r},st=Math.cos,ct=Math.sin,ht=Math.pow,ft=Math.abs,pt=Math.sqrt,gt=Math.asin,dt=Math.PI,mt=Object.freeze({linear:O,easeInQuad:_,easeOutQuad:L,easeInOutQuad:I,easeInCubic:x,easeOutCubic:M,easeInOutCubic:T,easeInQuart:E,easeOutQuart:A,easeInOutQuart:j,easeInQuint:Q,easeOutQuint:z,easeInOutQuint:B,easeInSine:D,easeOutSine:H,easeInOutSine:q,easeInExpo:P,easeOutExpo:F,easeInOutExpo:R,easeInCirc:W,easeOutCirc:$,easeInOutCirc:N,easeInElastic:X,easeOutElastic:Y,easeInOutElastic:J,easeInBack:V,easeOutBack:G,easeInOutBack:K,easeInBounce:U,easeOutBounce:Z,easeInOutBounce:tt}),vt=function(){function t(e){et.classCallCheck(this,t),this.el=e,this.props={},this.progress=!1,this.startTime=null}return et.createClass(t,[{key:"run",value:function(t,e,n,r,i){var o=this,l=arguments.length<=5||void 0===arguments[5]?function(){}:arguments[5];this.progress||(this.props={x:t,y:e},this.duration=n,this.delay=r,this.easing=i,this.callback=l,this.progress=!0,setTimeout(function(){o.startProps={x:b(o.el,"x"),y:b(o.el,"y")},ut(function(t){return o._loop(t)})},r))}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];this.startTime=null,this.progress=!1,t&&(k(this.el,this.props.x,"x"),k(this.el,this.props.y,"y")),l(this.callback)&&(this.callback(),this.callback=null)}},{key:"_loop",value:function(t){var e=this;if(this.startTime||(this.startTime=t),!this.progress)return void this.stop(!1);var n=this.el,r=this.props,i=this.duration,o=this.startTime,l=this.startProps,a={},u=mt[this.easing],s=t-o,h=Math.min(1,Math.max(s/i,0));c(r,function(t,e){var n=l[e],r=t-n;if(0===r)return!0;var o=u(h,i*h,0,1,i);a[e]=Math.round(n+r*o)}),c(a,function(t,e){k(n,t,e)}),i>=s?ut(function(t){return e._loop(t)}):this.stop(!0)}}]),t}(),yt=window,St=document,Ct="onwheel"in St?"wheel":"onmousewheel"in St?"mousewheel":"DOMMouseScroll",bt=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],n=arguments.length<=1||void 0===arguments[1]?"body, html":arguments[1];et.classCallCheck(this,t),this.options=s({},t.defaults,e),this.container=this.getContainer(n),this.header=f(this.options.header),this.tween=new vt(this.container),this._trigger=null,this._shouldCallCancelScroll=!1,this.bindContainerClick()}return et.createClass(t,[{key:"to",value:function(t){var e=this,n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=this.container,i=this.header,l=s({},this.options,n),a=this.parseCoodinate(l.offset),u=this._trigger,c=this.parseCoodinate(t);if(this._trigger=null,this._shouldCallCancelScroll=!1,this.stop(),r){if(!c&&o(t))if("#"===t)c={top:0,left:0};else if(!/[:,]/.test(t)){var h=f(t),p=w(h,r);if(!p)return;c=p}if(c){a&&(c.top+=a.top,c.left+=a.left),i&&(c.top=Math.max(0,c.top-this.header.clientHeight));var g=void 0,d=void 0;v(r)?(g={width:yt.innerWidth,height:yt.innerHeight},d={width:St.body.scrollWidth,height:St.body.scrollHeight}):(g={width:r.clientWidth,height:r.clientHeight},d={width:r.scrollWidth,height:r.scrollHeight}),this.hook(l.beforeScroll,c,u)!==!1&&this.beforeScroll(c,u)!==!1&&(l.verticalScroll?c.top=Math.max(0,Math.min(d.height-g.height,c.top)):c.top=b(r,"y"),l.horizontalScroll?c.left=Math.max(0,Math.min(d.width-g.width,c.left)):c.left=b(r,"x"),this.tween.run(c.left,c.top,l.duration,l.delay,l.easing,function(){e.unbindContainerStop(),e._shouldCallCancelScroll?(e.hook(l.cancelScroll),e.cancelScroll()):(e.hook(l.afterScroll,c,u),e.afterScroll(c,u))}),this.bindContainerStop())}}}},{key:"toTop",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,s({},e,{verticalScroll:!0,horizontalScroll:!1}))}},{key:"toLeft",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,s({},e,{verticalScroll:!1,horizontalScroll:!0}))}},{key:"toElement",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(t instanceof HTMLElement){var n=w(t,this.container);this.to(n,s({},e))}}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];this._stopScrollListener&&(this._shouldCallCancelScroll=!0),this.tween.stop(t)}},{key:"update",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.options=s({},this.options,t),this.header=f(this.options.header),this.bindContainerClick()}},{key:"destroy",value:function(){this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.container=null,this.header=null,this.tween=null}},{key:"beforeScroll",value:function(t,e){return!0}},{key:"cancelScroll",value:function(){}},{key:"afterScroll",value:function(t,e){}},{key:"parseCoodinate",value:function(t){var n=this.options.verticalScroll,r={top:0,left:0};if(u(t,"top")||u(t,"left"))r=s(r,t);else if(e(t))2===t.length?(r.top=t[0],r.left=t[1]):(r.top=n?t[0]:0,r.left=n?0:t[0]);else if(a(t))r.top=n?t:0,r.left=n?0:t;else{if(!o(t))return null;if(t=h(t),/^\d+,\d+$/.test(t))t=t.split(","),r.top=t[0],r.left=t[1];else if(/^(top|left):\d+,?(?:(top|left):\d+)?$/.test(t)){var i=t.match(/top:(\d+)/),l=t.match(/left:(\d+)/);r.top=i?i[1]:0,r.left=l?l[1]:0}else{if(!this.container||!/^(\+|-)=(\d+)$/.test(t))return null;var c=b(this.container,n?"y":"x"),f=t.match(/^(\+|-)\=(\d+)$/),p=f[1],g=parseInt(f[2],10);"+"===p?(r.top=n?c+g:0,r.left=n?0:c+g):(r.top=n?c-g:0,r.left=n?0:c-g)}}return r.top=parseInt(r.top,10),r.left=parseInt(r.left,10),r}},{key:"getContainer",value:function(t){var e=this.options,n=e.verticalScroll,r=e.horizontalScroll,i=void 0;return n&&(i=S(t,"y")),!i&&r&&(i=S(t,"x")),i}},{key:"bindContainerClick",value:function(){var t=this.container;t&&(this._containerClickListener=this.handleContainerClick.bind(this),d(t,"click",this._containerClickListener))}},{key:"unbindContainerClick",value:function(){var t=this.container;t&&this._containerClickListener&&(m(t,"click",this._containerClickListener),this._containerClickListener=null)}},{key:"bindContainerStop",value:function(){var t=this.container;t&&(this._stopScrollListener=this.handleStopScroll.bind(this),d(t,Ct,this._stopScrollListener),d(t,"touchstart",this._stopScrollListener),d(t,"touchmove",this._stopScrollListener))}},{key:"unbindContainerStop",value:function(){var t=this.container;t&&this._stopScrollListener&&(m(t,Ct,this._stopScrollListener),m(t,"touchstart",this._stopScrollListener),m(t,"touchmove",this._stopScrollListener),this._stopScrollListener=null)}},{key:"hook",value:function(t){if(l(t)){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;e>r;r++)n[r-1]=arguments[r];return t.apply(this,n)}}},{key:"handleStopScroll",value:function(t){this.options.stopScroll?this.stop():t.preventDefault()}},{key:"handleContainerClick",value:function(t){for(var e=this.options,n=t.target;n&&n!==St;n=n.parentNode)if(g(n,e.trigger)){var r=n.getAttribute("data-scroll"),i=this.parseDataOptions(n),o=r||n.getAttribute("href");e=s({},e,i),t.preventDefault(),t.stopPropagation(),this._trigger=n,e.horizontalScroll&&e.verticalScroll?this.to(o,e):e.verticalScroll?this.toTop(o,e):e.horizontalScroll&&this.toLeft(o,e)}}},{key:"parseDataOptions",value:function(t){var e=t.getAttribute("data-scroll-options");return e?JSON.parse(e):{}}}]),t}();return bt.defaults={trigger:"[data-scroll]",header:"[data-scroll-header]",duration:1e3,delay:0,easing:"easeOutQuint",offset:0,verticalScroll:!0,horizontalScroll:!1,stopScroll:!0,beforeScroll:null,afterScroll:null,cancelScroll:null},bt}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.SweetScroll=n()}(this,function(){"use strict";function t(t){return null==t?t+"":"object"===("undefined"==typeof t?"undefined":nt["typeof"](t))||"function"==typeof t?it[Object.prototype.toString.call(t)]||"object":"undefined"==typeof t?"undefined":nt["typeof"](t)}function n(t){return Array.isArray(t)}function e(t){var n=null==t?null:t.length;return i(n)&&n>=0&&et>=n}function r(e){return!n(e)&&"object"===t(e)}function i(n){return"number"===t(n)}function o(n){return"string"===t(n)}function l(n){return"function"===t(n)}function u(t){return!n(t)&&t-parseFloat(t)+1>=0}function a(t,n){return t&&t.hasOwnProperty(n)}function s(t){for(var n=arguments.length,e=Array(n>1?n-1:0),r=1;n>r;r++)e[r-1]=arguments[r];return c(e,function(n){c(n,function(n,e){t[e]=n})}),t}function c(t,n,i){if(null==t)return t;if(i=i||t,r(t)){for(var o in t)if(a(t,o)&&n.call(i,t[o],o)===!1)break}else if(e(t)){var l=void 0,u=t.length;for(l=0;u>l&&n.call(i,t[l],l)!==!1;l++);}return t}function f(t){return t.replace(/\s*/g,"")||""}function h(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(t)return(null==n?document:n).querySelector(t)}function p(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(t)return(null==n?document:n).querySelectorAll(t)}function g(t,n){for(var e=(t.document||t.ownerDocument).querySelectorAll(n),r=e.length;--r>=0&&e.item(r)!==t;);return r>-1}function d(t,n,e){var r=n.split(",");r.forEach(function(n){t.addEventListener(n.trim(),e,!1)})}function m(t,n,e){var r=n.split(",");r.forEach(function(n){t.removeEventListener(n.trim(),e,!1)})}function v(t){var n=document;return t===n.documentElement||t===n.body}function y(t){for(var n=arguments.length<=1||void 0===arguments[1]?"y":arguments[1],e=arguments.length<=2||void 0===arguments[2]?!0:arguments[2],r=ot[n],i=t instanceof HTMLElement?[t]:p(t),o=[],l=document.createElement("div"),u=0;u<i.length;u++){var a=i[u];if(a[r]>0?o.push(a):(l.style.width=a.clientWidth+1+"px",l.style.height=a.clientHeight+1+"px",a.appendChild(l),a[r]=1,a[r]>0&&o.push(a),a[r]=0,a.removeChild(l)),!e&&o.length>0)break}return o}function S(t,n){var e=y(t,n,!1);return e.length>=1?e[0]:void 0}function C(t){return null!=t&&t===t.window?t:9===t.nodeType&&t.defaultView}function b(t){var n=arguments.length<=1||void 0===arguments[1]?"y":arguments[1],e=ot[n],r=lt[n],i=C(t);return i?i[r]:t[e]}function k(t,n){var e=arguments.length<=2||void 0===arguments[2]?"y":arguments[2],r=ot[e],i=C(t),o="y"===e;i?i.scrollTo(o?i.pageXOffset:n,o?n:i.pageYOffset):t[r]=n}function w(t){var n=arguments.length<=1||void 0===arguments[1]?null:arguments[1];if(!t||t&&!t.getClientRects().length)return{top:0,left:0};var e=t.getBoundingClientRect();if(e.width||e.height){var r={},i=void 0;if(null==n||v(n))i=t.ownerDocument.documentElement,r.top=window.pageYOffset,r.left=window.pageXOffset;else{i=n;var o=i.getBoundingClientRect();r.top=-1*o.top+i.scrollTop,r.left=-1*o.left+i.scrollLeft}return{top:e.top+r.top-i.clientTop,left:e.left+r.left-i.clientLeft}}return e}function O(t){return t}function I(t,n,e,r,i){return r*(n/=i)*n+e}function x(t,n,e,r,i){return-r*(n/=i)*(n-2)+e}function _(t,n,e,r,i){return(n/=i/2)<1?r/2*n*n+e:-r/2*(--n*(n-2)-1)+e}function L(t,n,e,r,i){return r*(n/=i)*n*n+e}function E(t,n,e,r,i){return r*((n=n/i-1)*n*n+1)+e}function T(t,n,e,r,i){return(n/=i/2)<1?r/2*n*n*n+e:r/2*((n-=2)*n*n+2)+e}function M(t,n,e,r,i){return r*(n/=i)*n*n*n+e}function A(t,n,e,r,i){return-r*((n=n/i-1)*n*n*n-1)+e}function Q(t,n,e,r,i){return(n/=i/2)<1?r/2*n*n*n*n+e:-r/2*((n-=2)*n*n*n-2)+e}function j(t,n,e,r,i){return r*(n/=i)*n*n*n*n+e}function z(t,n,e,r,i){return r*((n=n/i-1)*n*n*n*n+1)+e}function B(t,n,e,r,i){return(n/=i/2)<1?r/2*n*n*n*n*n+e:r/2*((n-=2)*n*n*n*n+2)+e}function D(t,n,e,r,i){return-r*ct(n/i*(mt/2))+r+e}function H(t,n,e,r,i){return r*ft(n/i*(mt/2))+e}function q(t,n,e,r,i){return-r/2*(ct(mt*n/i)-1)+e}function P(t,n,e,r,i){return 0===n?e:r*ht(2,10*(n/i-1))+e}function F(t,n,e,r,i){return n===i?e+r:r*(-ht(2,-10*n/i)+1)+e}function R(t,n,e,r,i){return 0===n?e:n===i?e+r:(n/=i/2)<1?r/2*ht(2,10*(n-1))+e:r/2*(-ht(2,-10*--n)+2)+e}function W(t,n,e,r,i){return-r*(gt(1-(n/=i)*n)-1)+e}function $(t,n,e,r,i){return r*gt(1-(n=n/i-1)*n)+e}function N(t,n,e,r,i){return(n/=i/2)<1?-r/2*(gt(1-n*n)-1)+e:r/2*(gt(1-(n-=2)*n)+1)+e}function X(t,n,e,r,i){var o=1.70158,l=0,u=r;return 0===n?e:1===(n/=i)?e+r:(l||(l=.3*i),u<pt(r)?(u=r,o=l/4):o=l/(2*mt)*dt(r/u),-(u*ht(2,10*(n-=1))*ft((n*i-o)*(2*mt)/l))+e)}function Y(t,n,e,r,i){var o=1.70158,l=0,u=r;return 0===n?e:1===(n/=i)?e+r:(l||(l=.3*i),u<pt(r)?(u=r,o=l/4):o=l/(2*mt)*dt(r/u),u*ht(2,-10*n)*ft((n*i-o)*(2*mt)/l)+r+e)}function J(t,n,e,r,i){var o=1.70158,l=0,u=r;return 0===n?e:2===(n/=i/2)?e+r:(l||(l=i*(.3*1.5)),u<pt(r)?(u=r,o=l/4):o=l/(2*mt)*dt(r/u),1>n?-.5*(u*ht(2,10*(n-=1))*ft((n*i-o)*(2*mt)/l))+e:u*ht(2,-10*(n-=1))*ft((n*i-o)*(2*mt)/l)*.5+r+e)}function V(t,n,e,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return r*(n/=i)*n*((o+1)*n-o)+e}function G(t,n,e,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return r*((n=n/i-1)*n*((o+1)*n+o)+1)+e}function K(t,n,e,r,i){var o=arguments.length<=5||void 0===arguments[5]?1.70158:arguments[5];return(n/=i/2)<1?r/2*(n*n*(((o*=1.525)+1)*n-o))+e:r/2*((n-=2)*n*(((o*=1.525)+1)*n+o)+2)+e}function U(t,n,e,r,i){return r-Z(t,i-n,0,r,i)+e}function Z(t,n,e,r,i){return(n/=i)<1/2.75?r*(7.5625*n*n)+e:2/2.75>n?r*(7.5625*(n-=1.5/2.75)*n+.75)+e:2.5/2.75>n?r*(7.5625*(n-=2.25/2.75)*n+.9375)+e:r*(7.5625*(n-=2.625/2.75)*n+.984375)+e}function tt(t,n,e,r,i){return i/2>n?.5*U(t,2*n,0,r,i)+e:.5*Z(t,2*n-i,0,r,i)+.5*r+e}var nt={};nt["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},nt.classCallCheck=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},nt.createClass=function(){function t(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}();var et=Math.pow(2,53)-1,rt=["Boolean","Number","String","Function","Array","Object"],it={};rt.forEach(function(t){it["[object "+t+"]"]=t.toLowerCase()});var ot={y:"scrollTop",x:"scrollLeft"},lt={y:"pageYOffset",x:"pageXOffset"},ut=0,at=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){var n=Date.now(),e=Math.max(0,16-(n-ut)),r=window.setTimeout(function(){t(n+e)},e);return ut=n+e,r},st=Math,ct=st.cos,ft=st.sin,ht=st.pow,pt=st.abs,gt=st.sqrt,dt=st.asin,mt=st.PI,vt=Object.freeze({linear:O,InQuad:I,OutQuad:x,InOutQuad:_,InCubic:L,OutCubic:E,InOutCubic:T,InQuart:M,OutQuart:A,InOutQuart:Q,InQuint:j,OutQuint:z,InOutQuint:B,InSine:D,OutSine:H,InOutSine:q,InExpo:P,OutExpo:F,InOutExpo:R,InCirc:W,OutCirc:$,InOutCirc:N,InElastic:X,OutElastic:Y,InOutElastic:J,InBack:V,OutBack:G,InOutBack:K,InBounce:U,OutBounce:Z,InOutBounce:tt}),yt=function(){function t(n){nt.classCallCheck(this,t),this.el=n,this.props={},this.progress=!1,this.startTime=null}return nt.createClass(t,[{key:"run",value:function(t,n,e,r,i){var o=this,l=arguments.length<=5||void 0===arguments[5]?function(){}:arguments[5];this.progress||(this.props={x:t,y:n},this.duration=e,this.delay=r,this.easing=i.replace("ease",""),this.callback=l,this.progress=!0,setTimeout(function(){o.startProps={x:b(o.el,"x"),y:b(o.el,"y")},at(function(t){return o._loop(t)})},r))}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];this.startTime=null,this.progress=!1,t&&(k(this.el,this.props.x,"x"),k(this.el,this.props.y,"y")),l(this.callback)&&(this.callback(),this.callback=null)}},{key:"_loop",value:function(t){var n=this;if(this.startTime||(this.startTime=t),!this.progress)return void this.stop(!1);var e=this.el,r=this.props,i=this.duration,o=this.startTime,l=this.startProps,u={},a=vt[this.easing],s=t-o,f=Math.min(1,Math.max(s/i,0));c(r,function(t,n){var e=l[n],r=t-e;if(0===r)return!0;var o=a(f,i*f,0,1,i);u[n]=Math.round(e+r*o)}),c(u,function(t,n){k(e,t,n)}),i>=s?at(function(t){return n._loop(t)}):this.stop(!0)}}]),t}(),St=window,Ct=document,bt="onwheel"in Ct?"wheel":"onmousewheel"in Ct?"mousewheel":"DOMMouseScroll",kt=bt+", touchstart, touchmove",wt=function(){function t(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=arguments.length<=1||void 0===arguments[1]?"body, html":arguments[1];nt.classCallCheck(this,t),this.options=s({},t.defaults,n),this.container=this.getContainer(e),this.header=h(this.options.header),this.tween=new yt(this.container),this._trigger=null,this._shouldCallCancelScroll=!1,this.bindContainerClick()}return nt.createClass(t,[{key:"to",value:function(t){var n=this,e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=this.container,i=this.header,l=s({},this.options,e),u=this.parseCoodinate(l.offset),a=this._trigger,c=this.parseCoodinate(t);if(this._trigger=null,this._shouldCallCancelScroll=!1,this.stop(),r){if(!c&&o(t))if("#"===t)c={top:0,left:0};else if(!/[:,]/.test(t)){var f=h(t),p=w(f,r);if(!p)return;c=p}if(c){u&&(c.top+=u.top,c.left+=u.left),i&&(c.top=Math.max(0,c.top-this.header.clientHeight));var g=void 0,d=void 0;v(r)?(g={width:St.innerWidth,height:St.innerHeight},d={width:Ct.body.scrollWidth,height:Ct.body.scrollHeight}):(g={width:r.clientWidth,height:r.clientHeight},d={width:r.scrollWidth,height:r.scrollHeight}),this.hook(l.beforeScroll,c,a)!==!1&&this.beforeScroll(c,a)!==!1&&(l.verticalScroll?c.top=Math.max(0,Math.min(d.height-g.height,c.top)):c.top=b(r,"y"),l.horizontalScroll?c.left=Math.max(0,Math.min(d.width-g.width,c.left)):c.left=b(r,"x"),this.tween.run(c.left,c.top,l.duration,l.delay,l.easing,function(){n.unbindContainerStop(),n._shouldCallCancelScroll?(n.hook(l.cancelScroll),n.cancelScroll()):(n.hook(l.afterScroll,c,a),n.afterScroll(c,a))}),this.bindContainerStop())}}}},{key:"toTop",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,s({},n,{verticalScroll:!0,horizontalScroll:!1}))}},{key:"toLeft",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,s({},n,{verticalScroll:!1,horizontalScroll:!0}))}},{key:"toElement",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(t instanceof HTMLElement){var e=w(t,this.container);this.to(e,s({},n))}}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[0];this._stopScrollListener&&(this._shouldCallCancelScroll=!0),this.tween.stop(t)}},{key:"update",value:function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.options=s({},this.options,t),this.header=h(this.options.header),this.bindContainerClick()}},{key:"destroy",value:function(){this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.container=null,this.header=null,this.tween=null}},{key:"beforeScroll",value:function(t,n){return!0}},{key:"cancelScroll",value:function(){}},{key:"afterScroll",value:function(t,n){}},{key:"parseCoodinate",value:function(t){var e=this.options.verticalScroll,r={top:0,left:0};if(a(t,"top")||a(t,"left"))r=s(r,t);else if(n(t))2===t.length?(r.top=t[0],r.left=t[1]):(r.top=e?t[0]:0,r.left=e?0:t[0]);else if(u(t))r.top=e?t:0,r.left=e?0:t;else{if(!o(t))return null;if(t=f(t),/^\d+,\d+$/.test(t))t=t.split(","),r.top=t[0],r.left=t[1];else if(/^(top|left):\d+,?(?:(top|left):\d+)?$/.test(t)){var i=t.match(/top:(\d+)/),l=t.match(/left:(\d+)/);r.top=i?i[1]:0,r.left=l?l[1]:0}else{if(!this.container||!/^(\+|-)=(\d+)$/.test(t))return null;var c=b(this.container,e?"y":"x"),h=t.match(/^(\+|-)\=(\d+)$/),p=h[1],g=parseInt(h[2],10);"+"===p?(r.top=e?c+g:0,r.left=e?0:c+g):(r.top=e?c-g:0,r.left=e?0:c-g)}}return r.top=parseInt(r.top,10),r.left=parseInt(r.left,10),r}},{key:"getContainer",value:function(t){var n=this.options,e=n.verticalScroll,r=n.horizontalScroll,i=void 0;return e&&(i=S(t,"y")),!i&&r&&(i=S(t,"x")),i}},{key:"bindContainerClick",value:function(){var t=this.container;t&&(this._containerClickListener=this.handleContainerClick.bind(this),d(t,"click",this._containerClickListener))}},{key:"unbindContainerClick",value:function(){var t=this.container;t&&this._containerClickListener&&(m(t,"click",this._containerClickListener),this._containerClickListener=null)}},{key:"bindContainerStop",value:function(){var t=this.container;t&&(this._stopScrollListener=this.handleStopScroll.bind(this),d(t,kt,this._stopScrollListener))}},{key:"unbindContainerStop",value:function(){var t=this.container;t&&this._stopScrollListener&&(m(t,kt,this._stopScrollListener),this._stopScrollListener=null)}},{key:"hook",value:function(t){if(l(t)){for(var n=arguments.length,e=Array(n>1?n-1:0),r=1;n>r;r++)e[r-1]=arguments[r];return t.apply(this,e)}}},{key:"handleStopScroll",value:function(t){this.options.stopScroll?this.stop():t.preventDefault()}},{key:"handleContainerClick",value:function(t){for(var n=this.options,e=t.target;e&&e!==Ct;e=e.parentNode)if(g(e,n.trigger)){var r=e.getAttribute("data-scroll"),i=this.parseDataOptions(e),o=r||e.getAttribute("href");n=s({},n,i),t.preventDefault(),t.stopPropagation(),this._trigger=e,n.horizontalScroll&&n.verticalScroll?this.to(o,n):n.verticalScroll?this.toTop(o,n):n.horizontalScroll&&this.toLeft(o,n)}}},{key:"parseDataOptions",value:function(t){var n=t.getAttribute("data-scroll-options");return n?JSON.parse(n):{}}}]),t}();return wt.defaults={trigger:"[data-scroll]",header:"[data-scroll-header]",duration:1e3,delay:0,easing:"easeOutQuint",offset:0,verticalScroll:!0,horizontalScroll:!1,stopScroll:!0,beforeScroll:null,afterScroll:null,cancelScroll:null},wt}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
996
59875