sweet-scroll
Advanced tools
Comparing version 0.1.3 to 0.2.0
{ | ||
"name": "sweet-scroll", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Modern and the sweet smooth scroll library.", | ||
@@ -55,2 +55,3 @@ "main": "sweet-scroll.js", | ||
"karma-phantomjs-shim": "^1.1.2", | ||
"mocha": "^2.4.4", | ||
"phantomjs": "^1.9.19", | ||
@@ -57,0 +58,0 @@ "power-assert": "^1.2.0", |
@@ -210,2 +210,3 @@ sweet-scroll.js | ||
* `toLeft(distance, options = {})` | ||
* `toElement($el, options = {})` | ||
* `update(options = {})` | ||
@@ -306,2 +307,16 @@ * `stop(gotoEnd = false)` | ||
### toElement($el, options = {}) | ||
**$el: {HTMLElement}** | ||
**options: {object}** | ||
Scroll animation to the specified `HTMLElement`. | ||
**Example:** | ||
```javascript | ||
sweetScroll.toElement(document.getElementById("content")); | ||
``` | ||
### update(options = {}) | ||
@@ -308,0 +323,0 @@ |
@@ -8,3 +8,3 @@ /*! | ||
* @license MIT | ||
* @version 0.1.3 | ||
* @version 0.2.0 | ||
*/ | ||
@@ -17,3 +17,4 @@ (function (global, factory) { | ||
var babelHelpers_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
var babelHelpers = {}; | ||
babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { | ||
return typeof obj; | ||
@@ -24,3 +25,3 @@ } : function (obj) { | ||
var babelHelpers_classCallCheck = function (instance, Constructor) { | ||
babelHelpers.classCallCheck = function (instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
@@ -31,3 +32,3 @@ throw new TypeError("Cannot call a class as a function"); | ||
var babelHelpers_createClass = function () { | ||
babelHelpers.createClass = function () { | ||
function defineProperties(target, props) { | ||
@@ -50,4 +51,6 @@ for (var i = 0; i < props.length; i++) { | ||
babelHelpers; | ||
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; | ||
var classTypeList = ["Boolean", "Number", "String", "Function", "Array", "Date", "RegExp", "Object", "Error", "Symbol"]; | ||
var classTypeList = ["Boolean", "Number", "String", "Function", "Array", "Object"]; | ||
var classTypes = {}; | ||
@@ -63,3 +66,3 @@ | ||
} | ||
return (typeof obj === "undefined" ? "undefined" : babelHelpers_typeof(obj)) === "object" || typeof obj === "function" ? classTypes[Object.prototype.toString.call(obj)] || "object" : typeof obj === "undefined" ? "undefined" : babelHelpers_typeof(obj); | ||
return (typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj)) === "object" || typeof obj === "function" ? classTypes[Object.prototype.toString.call(obj)] || "object" : typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj); | ||
} | ||
@@ -267,2 +270,10 @@ | ||
function addEvent(el, event, listener) { | ||
el.addEventListener(event, listener, false); | ||
} | ||
function removeEvent(el, event, listener) { | ||
el.removeEventListener(event, listener, false); | ||
} | ||
var lastTime = 0; | ||
@@ -280,2 +291,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; | ||
function linear(p) { | ||
@@ -346,19 +365,19 @@ return p; | ||
function easeInSine(x, t, b, c, d) { | ||
return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; | ||
return -c * mathCos(t / d * (PI / 2)) + c + b; | ||
} | ||
function easeOutSine(x, t, b, c, d) { | ||
return c * Math.sin(t / d * (Math.PI / 2)) + b; | ||
return c * mathSin(t / d * (PI / 2)) + b; | ||
} | ||
function easeInOutSine(x, t, b, c, d) { | ||
return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; | ||
return -c / 2 * (mathCos(PI * t / d) - 1) + b; | ||
} | ||
function easeInExpo(x, t, b, c, d) { | ||
return t === 0 ? b : c * Math.pow(2, 10 * (t / d - 1)) + b; | ||
return t === 0 ? b : c * mathPow(2, 10 * (t / d - 1)) + b; | ||
} | ||
function easeOutExpo(x, t, b, c, d) { | ||
return t === d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; | ||
return t === d ? b + c : c * (-mathPow(2, -10 * t / d) + 1) + b; | ||
} | ||
@@ -369,12 +388,12 @@ | ||
if (t === d) return b + c; | ||
if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b; | ||
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; | ||
if ((t /= d / 2) < 1) return c / 2 * mathPow(2, 10 * (t - 1)) + b; | ||
return c / 2 * (-mathPow(2, -10 * --t) + 2) + b; | ||
} | ||
function easeInCirc(x, t, b, c, d) { | ||
return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b; | ||
return -c * (mathSqrt(1 - (t /= d) * t) - 1) + b; | ||
} | ||
function easeOutCirc(x, t, b, c, d) { | ||
return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; | ||
return c * mathSqrt(1 - (t = t / d - 1) * t) + b; | ||
} | ||
@@ -384,5 +403,5 @@ | ||
if ((t /= d / 2) < 1) { | ||
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b; | ||
return -c / 2 * (mathSqrt(1 - t * t) - 1) + b; | ||
} | ||
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b; | ||
return c / 2 * (mathSqrt(1 - (t -= 2) * t) + 1) + b; | ||
} | ||
@@ -397,9 +416,9 @@ | ||
if (!p) p = d * .3; | ||
if (a < Math.abs(c)) { | ||
if (a < mathAbs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
s = p / (2 * PI) * mathAsin(c / a); | ||
} | ||
return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; | ||
return -(a * mathPow(2, 10 * (t -= 1)) * mathSin((t * d - s) * (2 * PI) / p)) + b; | ||
} | ||
@@ -414,9 +433,9 @@ | ||
if (!p) p = d * .3; | ||
if (a < Math.abs(c)) { | ||
if (a < mathAbs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
s = p / (2 * PI) * mathAsin(c / a); | ||
} | ||
return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b; | ||
return a * mathPow(2, -10 * t) * mathSin((t * d - s) * (2 * PI) / p) + c + b; | ||
} | ||
@@ -431,12 +450,12 @@ | ||
if (!p) p = d * (.3 * 1.5); | ||
if (a < Math.abs(c)) { | ||
if (a < mathAbs(c)) { | ||
a = c; | ||
s = p / 4; | ||
} else { | ||
s = p / (2 * Math.PI) * Math.asin(c / a); | ||
s = p / (2 * PI) * mathAsin(c / a); | ||
} | ||
if (t < 1) { | ||
return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; | ||
return -.5 * (a * mathPow(2, 10 * (t -= 1)) * mathSin((t * d - s) * (2 * PI) / p)) + b; | ||
} | ||
return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b; | ||
return a * mathPow(2, -10 * (t -= 1)) * mathSin((t * d - s) * (2 * PI) / p) * .5 + c + b; | ||
} | ||
@@ -524,3 +543,3 @@ | ||
function ScrollTween(el) { | ||
babelHelpers_classCallCheck(this, ScrollTween); | ||
babelHelpers.classCallCheck(this, ScrollTween); | ||
@@ -533,3 +552,3 @@ this.el = el; | ||
babelHelpers_createClass(ScrollTween, [{ | ||
babelHelpers.createClass(ScrollTween, [{ | ||
key: "run", | ||
@@ -638,3 +657,3 @@ value: function run(x, y, duration, delay, easing) { | ||
var container = arguments.length <= 1 || arguments[1] === undefined ? "body, html" : arguments[1]; | ||
babelHelpers_classCallCheck(this, SweetScroll); | ||
babelHelpers.classCallCheck(this, SweetScroll); | ||
@@ -658,3 +677,3 @@ this.options = merge({}, SweetScroll.defaults, options); | ||
babelHelpers_createClass(SweetScroll, [{ | ||
babelHelpers.createClass(SweetScroll, [{ | ||
key: "to", | ||
@@ -781,2 +800,20 @@ value: function to(distance) { | ||
/** | ||
* Scroll animation to the specified element | ||
* @param {HTMLElement} | ||
* @param {object} | ||
* @return {void} | ||
*/ | ||
}, { | ||
key: "toElement", | ||
value: function toElement($el) { | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
if ($el instanceof HTMLElement) { | ||
var offset = getOffset($el, this.container); | ||
this.to(offset, merge({}, options)); | ||
} | ||
} | ||
/** | ||
* Stop the current animation | ||
@@ -867,5 +904,7 @@ * @param {boolean} | ||
value: function _bindContainerClick() { | ||
if (!this.container) return; | ||
var container = this.container; | ||
if (!container) return; | ||
this._containerClickListener = this._handleContainerClick.bind(this); | ||
this.container.addEventListener("click", this._containerClickListener, false); | ||
addEvent(container, "click", this._containerClickListener); | ||
} | ||
@@ -882,4 +921,6 @@ | ||
value: function _unbindContainerClick() { | ||
if (!this.container || !this._containerClickListener) return; | ||
this.container.removeEventListener("click", this._containerClickListener, false); | ||
var container = this.container; | ||
if (!container || !this._containerClickListener) return; | ||
removeEvent(container, "click", this._containerClickListener); | ||
this._containerClickListener = null; | ||
@@ -897,9 +938,9 @@ } | ||
value: function _bindContainerStop() { | ||
if (!this.container) return; | ||
var container = this.container; | ||
if (!container) return; | ||
this._stopScrollListener = this._handleStopScroll.bind(this); | ||
container.addEventListener(WHEEL_EVENT, this._stopScrollListener, false); | ||
container.addEventListener("touchstart", this._stopScrollListener, false); | ||
container.addEventListener("touchmove", this._stopScrollListener, false); | ||
addEvent(container, WHEEL_EVENT, this._stopScrollListener); | ||
addEvent(container, "touchstart", this._stopScrollListener); | ||
addEvent(container, "touchmove", this._stopScrollListener); | ||
} | ||
@@ -916,8 +957,8 @@ | ||
value: function _unbindContainerStop() { | ||
if (!this.container || !this._stopScrollListener) return; | ||
var container = this.container; | ||
container.removeEventListener(WHEEL_EVENT, this._stopScrollListener, false); | ||
container.removeEventListener("touchstart", this._stopScrollListener, false); | ||
container.removeEventListener("touchmove", this._stopScrollListener, false); | ||
if (!container || !this._stopScrollListener) return; | ||
removeEvent(container, WHEEL_EVENT, this._stopScrollListener); | ||
removeEvent(container, "touchstart", this._stopScrollListener); | ||
removeEvent(container, "touchmove", this._stopScrollListener); | ||
this._stopScrollListener = null; | ||
@@ -1015,4 +1056,4 @@ } | ||
scroll.top = parseInt(scroll.top); | ||
scroll.left = parseInt(scroll.left); | ||
scroll.top = parseInt(scroll.top, 10); | ||
scroll.left = parseInt(scroll.left, 10); | ||
@@ -1019,0 +1060,0 @@ return scroll; |
@@ -8,4 +8,4 @@ /*! | ||
* @license MIT | ||
* @version 0.1.3 | ||
* @version 0.2.0 | ||
*/ | ||
!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":Z(t))||"function"==typeof t?it[Object.prototype.toString.call(t)]||"object":"undefined"==typeof t?"undefined":Z(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 a(e){return"function"===t(e)}function s(t){return!e(t)&&t-parseFloat(t)+1>=0}function u(t,e){return t&&Object.prototype.hasOwnProperty.call(t,e)}function 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 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 a=void 0,s=t.length;for(a=0;s>a&&e.call(i,t[a],a)!==!1;a++);}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 d(t,e){for(var n=(t.document||t.ownerDocument).querySelectorAll(e),r=n.length;--r>=0&&n.item(r)!==t;);return r>-1}function g(t){var e=document;return t===e.documentElement||t===e.body}function m(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=[],a=document.createElement("div"),s=0;s<i.length;s++){var u=i[s];if(u[r]>0?o.push(u):(a.style.width=u.clientWidth+1+"px",a.style.height=u.clientHeight+1+"px",u.appendChild(a),u[r]=1,u[r]>0&&o.push(u),u[r]=0,u.removeChild(a)),!n&&o.length>0)break}return o}function v(t,e){var n=m(t,e,!1);return n.length>=1?n[0]:void 0}function y(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=at[e],i=y(t);return i?i[r]:t[n]}function S(t,e){var n=arguments.length<=2||void 0===arguments[2]?"y":arguments[2],r=ot[n],i=y(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||g(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 k(t){return t}function M(t,e,n,r,i){return r*(e/=i)*e+n}function _(t,e,n,r,i){return-r*(e/=i)*(e-2)+n}function C(t,e,n,r,i){return(e/=i/2)<1?r/2*e*e+n:-r/2*(--e*(e-2)-1)+n}function O(t,e,n,r,i){return r*(e/=i)*e*e+n}function I(t,e,n,r,i){return r*((e=e/i-1)*e*e+1)+n}function L(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 x(t,e,n,r,i){return r*(e/=i)*e*e*e+n}function E(t,e,n,r,i){return-r*((e=e/i-1)*e*e*e-1)+n}function T(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 P(t,e,n,r,i){return r*(e/=i)*e*e*e*e+n}function A(t,e,n,r,i){return r*((e=e/i-1)*e*e*e*e+1)+n}function j(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 q(t,e,n,r,i){return-r*Math.cos(e/i*(Math.PI/2))+r+n}function Q(t,e,n,r,i){return r*Math.sin(e/i*(Math.PI/2))+n}function z(t,e,n,r,i){return-r/2*(Math.cos(Math.PI*e/i)-1)+n}function B(t,e,n,r,i){return 0===e?n:r*Math.pow(2,10*(e/i-1))+n}function D(t,e,n,r,i){return e===i?n+r:r*(-Math.pow(2,-10*e/i)+1)+n}function H(t,e,n,r,i){return 0===e?n:e===i?n+r:(e/=i/2)<1?r/2*Math.pow(2,10*(e-1))+n:r/2*(-Math.pow(2,-10*--e)+2)+n}function R(t,e,n,r,i){return-r*(Math.sqrt(1-(e/=i)*e)-1)+n}function F(t,e,n,r,i){return r*Math.sqrt(1-(e=e/i-1)*e)+n}function W(t,e,n,r,i){return(e/=i/2)<1?-r/2*(Math.sqrt(1-e*e)-1)+n:r/2*(Math.sqrt(1-(e-=2)*e)+1)+n}function $(t,e,n,r,i){var o=1.70158,a=0,s=r;return 0===e?n:1===(e/=i)?n+r:(a||(a=.3*i),s<Math.abs(r)?(s=r,o=a/4):o=a/(2*Math.PI)*Math.asin(r/s),-(s*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/a))+n)}function N(t,e,n,r,i){var o=1.70158,a=0,s=r;return 0===e?n:1===(e/=i)?n+r:(a||(a=.3*i),s<Math.abs(r)?(s=r,o=a/4):o=a/(2*Math.PI)*Math.asin(r/s),s*Math.pow(2,-10*e)*Math.sin((e*i-o)*(2*Math.PI)/a)+r+n)}function X(t,e,n,r,i){var o=1.70158,a=0,s=r;return 0===e?n:2===(e/=i/2)?n+r:(a||(a=i*(.3*1.5)),s<Math.abs(r)?(s=r,o=a/4):o=a/(2*Math.PI)*Math.asin(r/s),1>e?-.5*(s*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/a))+n:s*Math.pow(2,-10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/a)*.5+r+n)}function Y(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 J(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 V(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 G(t,e,n,r,i){return r-K(t,i-e,0,r,i)+n}function K(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 U(t,e,n,r,i){return i/2>e?.5*G(t,2*e,0,r,i)+n:.5*K(t,2*e-i,0,r,i)+.5*r+n}var Z="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},tt=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},et=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}}(),nt=Math.pow(2,53)-1,rt=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error","Symbol"],it={};rt.forEach(function(t){it["[object "+t+"]"]=t.toLowerCase()});var ot={y:"scrollTop",x:"scrollLeft"},at={y:"pageYOffset",x:"pageXOffset"},st=0,ut=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){var e=Date.now(),n=Math.max(0,16-(e-st)),r=window.setTimeout(function(){t(e+n)},n);return st=e+n,r},lt=Object.freeze({linear:k,easeInQuad:M,easeOutQuad:_,easeInOutQuad:C,easeInCubic:O,easeOutCubic:I,easeInOutCubic:L,easeInQuart:x,easeOutQuart:E,easeInOutQuart:T,easeInQuint:P,easeOutQuint:A,easeInOutQuint:j,easeInSine:q,easeOutSine:Q,easeInOutSine:z,easeInExpo:B,easeOutExpo:D,easeInOutExpo:H,easeInCirc:R,easeOutCirc:F,easeInOutCirc:W,easeInElastic:$,easeOutElastic:N,easeInOutElastic:X,easeInBack:Y,easeOutBack:J,easeInOutBack:V,easeInBounce:G,easeOutBounce:K,easeInOutBounce:U}),ct=function(){function t(e){tt(this,t),this.el=e,this.props={},this.progress=!1,this.startTime=null}return et(t,[{key:"run",value:function(t,e,n,r,i){var o=this,a=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=a,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&&(S(this.el,this.props.x,"x"),S(this.el,this.props.y,"y")),a(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,a=this.startProps,s={},u=lt[this.easing],l=t-o,h=Math.min(1,Math.max(l/i,0));c(r,function(t,e){var n=a[e],r=t-n;if(0===r)return!0;var o=u(h,i*h,0,1,i);s[e]=Math.round(n+r*o)}),c(s,function(t,e){S(n,t,e)}),i>=l?ut(function(t){return e._loop(t)}):this.stop(!0)}}]),t}(),ht=window,ft=document,pt="onwheel"in ft?"wheel":"onmousewheel"in ft?"mousewheel":"DOMMouseScroll",dt=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];tt(this,t),this.options=l({},t.defaults,e),this.container=this._getContainer(n),this.header=f(this.options.header),this.tween=new ct(this.container),this._trigger=null,this._bindContainerClick()}return et(t,[{key:"to",value:function(t){var e=this,n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=this.container,i=l({},this.options,n),a=this._parseCoodinate(i.offset),s=this._trigger,u=this._parseCoodinate(t);if(this._trigger=null,this.stop(),r){if(!u&&o(t))if("#"===t)u={top:0,left:0};else if(!/[:,]/.test(t)){var c=f(t),h=w(c,r);if(!h)return;u=h}if(u){a&&(u.top+=a.top,u.left+=a.left),this.header&&(u.top=Math.max(0,u.top-this.header.clientHeight));var p=void 0,d=void 0;g(r)?(p={width:ht.innerWidth,height:ht.innerHeight},d={width:ft.body.scrollWidth,height:ft.body.scrollHeight}):(p={width:r.clientWidth,height:r.clientHeight},d={width:r.scrollWidth,height:r.scrollHeight}),i.verticalScroll?u.top=Math.max(0,Math.min(d.height-p.height,u.top)):u.top=b(r,"y"),i.horizontalScroll?u.left=Math.max(0,Math.min(d.width-p.width,u.left)):u.left=b(r,"x"),this._hook(i.beforeScroll,u,s)!==!1&&(this.tween.run(u.left,u.top,i.duration,i.delay,i.easing,function(){e._unbindContainerStop(),e._hook(i.afterScroll,u,s)}),this._bindContainerStop())}}}},{key:"toTop",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,l({},e,{verticalScroll:!0,horizontalScroll:!1}))}},{key:"toLeft",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,l({},e,{verticalScroll:!1,horizontalScroll:!0}))}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[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=l({},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:"_getContainer",value:function(t){var e=this.options,n=e.verticalScroll,r=e.horizontalScroll,i=void 0;return n&&(i=v(t,"y")),!i&&r&&(i=v(t,"x")),i}},{key:"_bindContainerClick",value:function(){this.container&&(this._containerClickListener=this._handleContainerClick.bind(this),this.container.addEventListener("click",this._containerClickListener,!1))}},{key:"_unbindContainerClick",value:function(){this.container&&this._containerClickListener&&(this.container.removeEventListener("click",this._containerClickListener,!1),this._containerClickListener=null)}},{key:"_bindContainerStop",value:function(){if(this.container){var t=this.container;this._stopScrollListener=this._handleStopScroll.bind(this),t.addEventListener(pt,this._stopScrollListener,!1),t.addEventListener("touchstart",this._stopScrollListener,!1),t.addEventListener("touchmove",this._stopScrollListener,!1)}}},{key:"_unbindContainerStop",value:function(){if(this.container&&this._stopScrollListener){var t=this.container;t.removeEventListener(pt,this._stopScrollListener,!1),t.removeEventListener("touchstart",this._stopScrollListener,!1),t.removeEventListener("touchmove",this._stopScrollListener,!1),this._stopScrollListener=null}}},{key:"_hook",value:function(t){if(a(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:"_parseCoodinate",value:function(t){var n=this.options.verticalScroll,r={top:0,left:0};if(u(t,"top")||u(t,"left"))r=l(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(s(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+)/),a=t.match(/left:(\d+)/);r.top=i?i[1]:0,r.left=a?a[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],d=parseInt(f[2],10);"+"===p?(r.top=n?c+d:0,r.left=n?0:c+d):(r.top=n?c-d:0,r.left=n?0:c-d)}}return r.top=parseInt(r.top),r.left=parseInt(r.left),r}},{key:"_handleStopScroll",value:function(t){this.options.stopScroll?this._hook(this.options.cancelScroll)!==!1&&this.stop():t.preventDefault()}},{key:"_handleContainerClick",value:function(t){for(var e=this.options,n=t.target;n&&n!==ft;n=n.parentNode)if(d(n,e.trigger)){var r=n.getAttribute("data-scroll"),i=this._parseDataOptions(n),o=r||n.getAttribute("href");e=l({},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 dt.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},dt}); | ||
!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 a(e){return"function"===t(e)}function u(t){return!e(t)&&t-parseFloat(t)+1>=0}function s(t,e){return t&&Object.prototype.hasOwnProperty.call(t,e)}function 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 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(s(t,o)&&e.call(i,t[o],o)===!1)break}else if(n(t)){var a=void 0,u=t.length;for(a=0;u>a&&e.call(i,t[a],a)!==!1;a++);}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){var e=document;return t===e.documentElement||t===e.body}function m(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=[],a=document.createElement("div"),u=0;u<i.length;u++){var s=i[u];if(s[r]>0?o.push(s):(a.style.width=s.clientWidth+1+"px",a.style.height=s.clientHeight+1+"px",s.appendChild(a),s[r]=1,s[r]>0&&o.push(s),s[r]=0,s.removeChild(a)),!n&&o.length>0)break}return o}function v(t,e){var n=m(t,e,!1);return n.length>=1?n[0]:void 0}function y(t){return null!=t&&t===t.window?t:9===t.nodeType&&t.defaultView}function S(t){var e=arguments.length<=1||void 0===arguments[1]?"y":arguments[1],n=ot[e],r=at[e],i=y(t);return i?i[r]:t[n]}function b(t,e){var n=arguments.length<=2||void 0===arguments[2]?"y":arguments[2],r=ot[n],i=y(t),o="y"===n;i?i.scrollTo(o?i.pageXOffset:e,o?e:i.pageYOffset):t[r]=e}function C(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||d(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 k(t,e,n){t.addEventListener(e,n,!1)}function _(t,e,n){t.removeEventListener(e,n,!1)}function w(t){return t}function O(t,e,n,r,i){return r*(e/=i)*e+n}function I(t,e,n,r,i){return-r*(e/=i)*(e-2)+n}function L(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*lt(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*(lt(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,a=0,u=r;return 0===e?n:1===(e/=i)?n+r:(a||(a=.3*i),u<ft(r)?(u=r,o=a/4):o=a/(2*dt)*gt(r/u),-(u*ht(2,10*(e-=1))*ct((e*i-o)*(2*dt)/a))+n)}function Y(t,e,n,r,i){var o=1.70158,a=0,u=r;return 0===e?n:1===(e/=i)?n+r:(a||(a=.3*i),u<ft(r)?(u=r,o=a/4):o=a/(2*dt)*gt(r/u),u*ht(2,-10*e)*ct((e*i-o)*(2*dt)/a)+r+n)}function J(t,e,n,r,i){var o=1.70158,a=0,u=r;return 0===e?n:2===(e/=i/2)?n+r:(a||(a=i*(.3*1.5)),u<ft(r)?(u=r,o=a/4):o=a/(2*dt)*gt(r/u),1>e?-.5*(u*ht(2,10*(e-=1))*ct((e*i-o)*(2*dt)/a))+n:u*ht(2,-10*(e-=1))*ct((e*i-o)*(2*dt)/a)*.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"},at={y:"pageYOffset",x:"pageXOffset"},ut=0,st=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(t){var e=Date.now(),n=Math.max(0,16-(e-ut)),r=window.setTimeout(function(){t(e+n)},n);return ut=e+n,r},lt=Math.cos,ct=Math.sin,ht=Math.pow,ft=Math.abs,pt=Math.sqrt,gt=Math.asin,dt=Math.PI,mt=Object.freeze({linear:w,easeInQuad:O,easeOutQuad:I,easeInOutQuad:L,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,a=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=a,this.progress=!0,setTimeout(function(){o.startProps={x:S(o.el,"x"),y:S(o.el,"y")},st(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&&(b(this.el,this.props.x,"x"),b(this.el,this.props.y,"y")),a(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,a=this.startProps,u={},s=mt[this.easing],l=t-o,h=Math.min(1,Math.max(l/i,0));c(r,function(t,e){var n=a[e],r=t-n;if(0===r)return!0;var o=s(h,i*h,0,1,i);u[e]=Math.round(n+r*o)}),c(u,function(t,e){b(n,t,e)}),i>=l?st(function(t){return e._loop(t)}):this.stop(!0)}}]),t}(),yt=window,St=document,bt="onwheel"in St?"wheel":"onmousewheel"in St?"mousewheel":"DOMMouseScroll",Ct=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=l({},t.defaults,e),this.container=this._getContainer(n),this.header=f(this.options.header),this.tween=new vt(this.container),this._trigger=null,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=l({},this.options,n),a=this._parseCoodinate(i.offset),u=this._trigger,s=this._parseCoodinate(t);if(this._trigger=null,this.stop(),r){if(!s&&o(t))if("#"===t)s={top:0,left:0};else if(!/[:,]/.test(t)){var c=f(t),h=C(c,r);if(!h)return;s=h}if(s){a&&(s.top+=a.top,s.left+=a.left),this.header&&(s.top=Math.max(0,s.top-this.header.clientHeight));var p=void 0,g=void 0;d(r)?(p={width:yt.innerWidth,height:yt.innerHeight},g={width:St.body.scrollWidth,height:St.body.scrollHeight}):(p={width:r.clientWidth,height:r.clientHeight},g={width:r.scrollWidth,height:r.scrollHeight}),i.verticalScroll?s.top=Math.max(0,Math.min(g.height-p.height,s.top)):s.top=S(r,"y"),i.horizontalScroll?s.left=Math.max(0,Math.min(g.width-p.width,s.left)):s.left=S(r,"x"),this._hook(i.beforeScroll,s,u)!==!1&&(this.tween.run(s.left,s.top,i.duration,i.delay,i.easing,function(){e._unbindContainerStop(),e._hook(i.afterScroll,s,u)}),this._bindContainerStop())}}}},{key:"toTop",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,l({},e,{verticalScroll:!0,horizontalScroll:!1}))}},{key:"toLeft",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];this.to(t,l({},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=C(t,this.container);this.to(n,l({},e))}}},{key:"stop",value:function(){var t=arguments.length<=0||void 0===arguments[0]?!1:arguments[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=l({},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:"_getContainer",value:function(t){var e=this.options,n=e.verticalScroll,r=e.horizontalScroll,i=void 0;return n&&(i=v(t,"y")),!i&&r&&(i=v(t,"x")),i}},{key:"_bindContainerClick",value:function(){var t=this.container;t&&(this._containerClickListener=this._handleContainerClick.bind(this),k(t,"click",this._containerClickListener))}},{key:"_unbindContainerClick",value:function(){var t=this.container;t&&this._containerClickListener&&(_(t,"click",this._containerClickListener),this._containerClickListener=null)}},{key:"_bindContainerStop",value:function(){var t=this.container;t&&(this._stopScrollListener=this._handleStopScroll.bind(this),k(t,bt,this._stopScrollListener),k(t,"touchstart",this._stopScrollListener),k(t,"touchmove",this._stopScrollListener))}},{key:"_unbindContainerStop",value:function(){var t=this.container;t&&this._stopScrollListener&&(_(t,bt,this._stopScrollListener),_(t,"touchstart",this._stopScrollListener),_(t,"touchmove",this._stopScrollListener),this._stopScrollListener=null)}},{key:"_hook",value:function(t){if(a(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:"_parseCoodinate",value:function(t){var n=this.options.verticalScroll,r={top:0,left:0};if(s(t,"top")||s(t,"left"))r=l(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(u(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+)/),a=t.match(/left:(\d+)/);r.top=i?i[1]:0,r.left=a?a[1]:0}else{if(!this.container||!/^(\+|-)=(\d+)$/.test(t))return null;var c=S(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:"_handleStopScroll",value:function(t){this.options.stopScroll?this._hook(this.options.cancelScroll)!==!1&&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=l({},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 Ct.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},Ct}); |
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
58349
950
449
29