Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sweet-scroll

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweet-scroll - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

13

CHANGELOG.md

@@ -0,1 +1,14 @@

## 2.1.0
### New feature
* Add `quickMode` options
- Instantly scroll to the destination! (It's recommended to use it with `easeOutExpo`)
### Minor changes
* Update doc
* Update devDependencies
## 2.0.1

@@ -2,0 +15,0 @@

12

package.json
{
"name": "sweet-scroll",
"version": "2.0.1",
"version": "2.1.0",
"description": "Modern and the sweet smooth scroll library.",

@@ -46,3 +46,3 @@ "main": "sweet-scroll.js",

"devDependencies": {
"autoprefixer": "^6.5.1",
"autoprefixer": "^6.5.3",
"babel-eslint": "^7.1.0",

@@ -57,3 +57,3 @@ "babel-plugin-espower": "^2.3.1",

"copyfiles": "^1.0.0",
"eslint": "^3.9.0",
"eslint": "^3.9.1",
"karma": "^1.3.0",

@@ -64,7 +64,7 @@ "karma-browserify": "^5.1.0",

"karma-html2js-preprocessor": "^1.1.0",
"karma-mocha": "^1.2.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"mocha": "^3.1.2",
"node-sass": "^3.10.1",
"node-sass": "^3.11.2",
"npm-run-all": "^3.1.1",

@@ -74,3 +74,3 @@ "onchange": "^3.0.2",

"postcss-cli": "^2.6.0",
"power-assert": "^1.4.1",
"power-assert": "^1.4.2",
"rollup": "^0.36.3",

@@ -77,0 +77,0 @@ "rollup-plugin-babel": "^2.6.1",

@@ -95,2 +95,3 @@ <img src="https://raw.githubusercontent.com/tsuyoshiwada/sweet-scroll/images/logo.png" width="340" height="135" alt="sweet-scroll.js">

outputLog: false, // Specify level of output to log
quickMode: false, // Instantly scroll to the destination! (It's recommended to use it with `easeOutExpo`)

@@ -216,2 +217,17 @@ // Callbacks

#### Do you feel scrolling is slow?
You can solve with `quickMode` options!
```javascript
const sweetScroll = new SweetScroll({
quickMode: true,
easing: "easeOutExpo" // Recommended
});
```
`quickMode` finishes scrolling in a moment.
#### Scroll animation in a other page

@@ -218,0 +234,0 @@

@@ -29,6 +29,3 @@ import * as Util from "./utils";

setTimeout(() => {
this.startProps = {
x: Dom.getScroll(this.el, "x"),
y: Dom.getScroll(this.el, "y")
};
this.startProps = this.calcStartProps(x, y);
this.rafId = raf(time => this._loop(time));

@@ -92,2 +89,23 @@ }, this.options.delay);

}
calcStartProps(x, y) {
const startProps = {
x: Dom.getScroll(this.el, "x"),
y: Dom.getScroll(this.el, "y")
};
if (this.options.quickMode) {
const { viewport: { width, height } } = Dom.getViewportAndElementSizes(this.el);
if (math.abs(startProps.y - y) > height) {
startProps.y = startProps.y > y ? y + height : y - height;
}
if (math.abs(startProps.x - x) > width) {
startProps.x = startProps.x > x ? x + width : x - width;
}
}
return startProps;
}
}

@@ -42,2 +42,3 @@ import * as Util from "./utils";

outputLog: false, // Specify level of output to log
quickMode: false, // Instantly scroll to the destination! (It's recommended to use it with `easeOutExpo`)

@@ -214,2 +215,3 @@ // Callbacks

easing: params.easing,
quickMode: params.quickMode,
complete: () => {

@@ -216,0 +218,0 @@ // Update URL

@@ -6,3 +6,3 @@ /*!

* @license MIT
* @version 2.0.1
* @version 2.1.0
*/

@@ -855,6 +855,3 @@

setTimeout(function () {
_this.startProps = {
x: getScroll(_this.el, "x"),
y: getScroll(_this.el, "y")
};
_this.startProps = _this.calcStartProps(x, y);
_this.rafId = raf(function (time) {

@@ -935,2 +932,27 @@ return _this._loop(time);

}
}, {
key: "calcStartProps",
value: function calcStartProps(x, y) {
var startProps = {
x: getScroll(this.el, "x"),
y: getScroll(this.el, "y")
};
if (this.options.quickMode) {
var _Dom$getViewportAndEl = getViewportAndElementSizes(this.el),
_Dom$getViewportAndEl2 = _Dom$getViewportAndEl.viewport,
width = _Dom$getViewportAndEl2.width,
height = _Dom$getViewportAndEl2.height;
if (abs(startProps.y - y) > height) {
startProps.y = startProps.y > y ? y + height : y - height;
}
if (abs(startProps.x - x) > width) {
startProps.x = startProps.x > x ? x + width : x - width;
}
}
return startProps;
}
}]);

@@ -1144,2 +1166,3 @@ return ScrollTween;

easing: params.easing,
quickMode: params.quickMode,
complete: function complete() {

@@ -1652,2 +1675,3 @@ // Update URL

outputLog: false, // Specify level of output to log
quickMode: false, // Instantly scroll to the destination! (It's recommended to use it with `easeOutExpo`)

@@ -1654,0 +1678,0 @@ // Callbacks

@@ -6,4 +6,4 @@ /*!

* @license MIT
* @version 2.0.1
* @version 2.1.0
*/
!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?"":"object"===("undefined"==typeof t?"undefined":St(t))||"function"==typeof t?wt[Object.prototype.toString.call(t)]||"object":"undefined"==typeof t?"undefined":St(t)}function n(n){return"number"===t(n)}function e(n){return"string"===t(n)}function o(n){return"function"===t(n)}function i(t){return Array.isArray(t)}function r(t){var e=null==t?null:t.length;return n(e)&&e>=0&&e<=bt}function l(t){return!i(t)&&t-parseFloat(t)+1>=0}function u(n){return!i(n)&&"object"===t(n)}function a(t,n){return t&&t.hasOwnProperty(n)}function c(t,n,e){if(null==t)return t;var o=e||t;if(u(t)){for(var i in t)if(a(t,i)&&n.call(o,t[i],i)===!1)break}else if(r(t))for(var l=0;l<t.length&&n.call(o,t[l],l)!==!1;l++);return t}function s(t){for(var n=arguments.length,e=Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return c(e,function(n){c(n,function(n,e){t[e]=n})}),t}function h(t){return t.replace(/\s*/g,"")||""}function f(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw new Error(t)}catch(t){}}function p(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t)return(null==n?_t:n).querySelector(t)}function d(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t)return(null==n?_t:n).querySelectorAll(t)}function v(t,n){for(var e=(t.document||t.ownerDocument).querySelectorAll(n),o=e.length;--o>=0&&e.item(o)!==t;);return o>-1}function y(t){return t===_t.documentElement||t===_t.body}function g(){var t=Ot.outerWidth,n=Ot.innerWidth;return t?t/n:1}function S(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=It[n],i=t instanceof Element?[t]:d(t),r=[],l=_t.createElement("div"),u=0;u<i.length;u++){var a=i[u];if(a[o]>0?r.push(a):(l.style.width=a.clientWidth+1+"px",l.style.height=a.clientHeight+1+"px",a.appendChild(l),a[o]=1.5/g(),a[o]>0&&r.push(a),a[o]=0,a.removeChild(l)),!e&&r.length>0)break}return r}function m(t,n){var e=S(t,n,!1);return e.length>=1?e[0]:null}function k(t){return null!=t&&t===t.window?t:9===t.nodeType&&t.defaultView}function b(t){return vt(t.scrollHeight,t.clientHeight,t.offsetHeight)}function C(t){return vt(t.scrollWidth,t.clientWidth,t.offsetWidth)}function w(t){return{width:C(t),height:b(t)}}function O(){return{width:vt(C(_t.body),C(_t.documentElement)),height:vt(b(_t.body),b(_t.documentElement))}}function _(t){return y(t)?{viewport:{width:yt(Ot.innerWidth,_t.documentElement.clientWidth),height:Ot.innerHeight},size:O()}:{viewport:{width:t.clientWidth,height:t.clientHeight},size:w(t)}}function I(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",e=k(t);return e?e[xt[n]]:t[It[n]]}function x(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"y",o=k(t),i="y"===e;o?o.scrollTo(i?o[xt.x]:n,i?n:o[xt.y]):t[It[e]]=n}function L(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t||t&&!t.getClientRects().length)return{top:0,left:0};var e=t.getBoundingClientRect();if(e.width||e.height){var o={},i=null;if(null==n||y(n))i=t.ownerDocument.documentElement,o.top=Ot.pageYOffset,o.left=Ot.pageXOffset;else{i=n;var r=i.getBoundingClientRect();o.top=r.top*-1+i.scrollTop,o.left=r.left*-1+i.scrollLeft}return{top:e.top+o.top-i.clientTop,left:e.left+o.left-i.clientLeft}}return e}function E(t,n,e){var o=n.split(",");o.forEach(function(n){t.addEventListener(n.trim(),e,!1)})}function A(t,n,e){var o=n.split(",");o.forEach(function(n){t.removeEventListener(n.trim(),e,!1)})}function T(t){return t}function z(t,n,e,o,i){return o*(n/=i)*n+e}function M(t,n,e,o,i){return-o*(n/=i)*(n-2)+e}function j(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n+e:-o/2*(--n*(n-2)-1)+e}function D(t,n,e,o,i){return o*(n/=i)*n*n+e}function P(t,n,e,o,i){return o*((n=n/i-1)*n*n+1)+e}function Q(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n+e:o/2*((n-=2)*n*n+2)+e}function W(t,n,e,o,i){return o*(n/=i)*n*n*n+e}function B(t,n,e,o,i){return-o*((n=n/i-1)*n*n*n-1)+e}function R(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n*n+e:-o/2*((n-=2)*n*n*n-2)+e}function H(t,n,e,o,i){return o*(n/=i)*n*n*n*n+e}function N(t,n,e,o,i){return o*((n=n/i-1)*n*n*n*n+1)+e}function q(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n*n*n+e:o/2*((n-=2)*n*n*n*n+2)+e}function F(t,n,e,o,i){return-o*at(n/i*(dt/2))+o+e}function U(t,n,e,o,i){return o*ct(n/i*(dt/2))+e}function $(t,n,e,o,i){return-o/2*(at(dt*n/i)-1)+e}function X(t,n,e,o,i){return 0===n?e:o*st(2,10*(n/i-1))+e}function Y(t,n,e,o,i){return n===i?e+o:o*(-st(2,-10*n/i)+1)+e}function J(t,n,e,o,i){return 0===n?e:n===i?e+o:(n/=i/2)<1?o/2*st(2,10*(n-1))+e:o/2*(-st(2,-10*--n)+2)+e}function V(t,n,e,o,i){return-o*(ft(1-(n/=i)*n)-1)+e}function G(t,n,e,o,i){return o*ft(1-(n=n/i-1)*n)+e}function K(t,n,e,o,i){return(n/=i/2)<1?-o/2*(ft(1-n*n)-1)+e:o/2*(ft(1-(n-=2)*n)+1)+e}function Z(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:1===(n/=i)?e+o:(l||(l=.3*i),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),-(u*st(2,10*(n-=1))*ct((n*i-r)*(2*dt)/l))+e)}function tt(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:1===(n/=i)?e+o:(l||(l=.3*i),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),u*st(2,-10*n)*ct((n*i-r)*(2*dt)/l)+o+e)}function nt(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:2===(n/=i/2)?e+o:(l||(l=i*(.3*1.5)),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),n<1?-.5*(u*st(2,10*(n-=1))*ct((n*i-r)*(2*dt)/l))+e:u*st(2,-10*(n-=1))*ct((n*i-r)*(2*dt)/l)*.5+o+e)}function et(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return o*(n/=i)*n*((r+1)*n-r)+e}function ot(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return o*((n=n/i-1)*n*((r+1)*n+r)+1)+e}function it(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return(n/=i/2)<1?o/2*(n*n*(((r*=1.525)+1)*n-r))+e:o/2*((n-=2)*n*(((r*=1.525)+1)*n+r)+2)+e}function rt(t,n,e,o,i){return(n/=i)<1/2.75?o*(7.5625*n*n)+e:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+e:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+e:o*(7.5625*(n-=2.625/2.75)*n+.984375)+e}function lt(t,n,e,o,i){return o-rt(t,i-n,0,o,i)+e}function ut(t,n,e,o,i){return n<i/2?.5*lt(t,2*n,0,o,i)+e:.5*rt(t,2*n-i,0,o,i)+.5*o+e}var at=Math.cos,ct=Math.sin,st=Math.pow,ht=Math.abs,ft=Math.sqrt,pt=Math.asin,dt=Math.PI,vt=Math.max,yt=Math.min,gt=Math.round,St="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},mt=(function(){function t(t){this.value=t}function n(n){function e(t,n){return new Promise(function(e,i){var u={key:t,arg:n,resolve:e,reject:i,next:null};l?l=l.next=u:(r=l=u,o(t,n))})}function o(e,r){try{var l=n[e](r),u=l.value;u instanceof t?Promise.resolve(u.value).then(function(t){o("next",t)},function(t){o("throw",t)}):i(l.done?"return":"normal",l.value)}catch(t){i("throw",t)}}function i(t,n){switch(t){case"return":r.resolve({value:n,done:!0});break;case"throw":r.reject(n);break;default:r.resolve({value:n,done:!1})}r=r.next,r?o(r.key,r.arg):l=null}var r,l;this._invoke=e,"function"!=typeof n.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(t){return this._invoke("next",t)},n.prototype.throw=function(t){return this._invoke("throw",t)},n.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new n(t.apply(this,arguments))}},await:function(n){return new t(n)}}}(),function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}),kt=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),bt=st(2,53)-1,Ct=["Boolean","Number","String","Function","Array","Object"],wt={};Ct.forEach(function(t){wt["[object "+t+"]"]=t.toLowerCase()});for(var Ot=window,_t=document,It={y:"scrollTop",x:"scrollLeft"},xt={y:"pageYOffset",x:"pageXOffset"},Lt=(function(){var t=navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(Ot.history&&"pushState"in Ot.history&&"file:"!==Ot.location.protocol)}()),Et=Object.freeze({linear:T,InQuad:z,OutQuad:M,InOutQuad:j,InCubic:D,OutCubic:P,InOutCubic:Q,InQuart:W,OutQuart:B,InOutQuart:R,InQuint:H,OutQuint:N,InOutQuint:q,InSine:F,OutSine:U,InOutSine:$,InExpo:X,OutExpo:Y,InOutExpo:J,InCirc:V,OutCirc:G,InOutCirc:K,InElastic:Z,OutElastic:tt,InOutElastic:nt,InBack:et,OutBack:ot,InOutBack:it,OutBounce:rt,InBounce:lt,InOutBounce:ut}),At=["ms","moz","webkit"],Tt=0,zt=Ot.requestAnimationFrame,Mt=Ot.cancelAnimationFrame,jt=0;jt<At.length&&!zt;++jt)zt=Ot[At[jt]+"RequestAnimationFrame"],Mt=Ot[At[jt]+"CancelAnimationFrame"]||Ot[At[jt]+"CancelRequestAnimationFrame"];zt||(zt=function(t){var n=Date.now(),e=vt(0,16-(n-Tt)),o=setTimeout(function(){t(n+e)},e);return Tt=n+e,o}),Mt||(Mt=function(t){clearTimeout(t)});var Dt=function(){function t(n){mt(this,t),this.el=n,this.props={},this.options={},this.progress=!1,this.easing=null,this.startTime=null,this.rafId=null}return kt(t,[{key:"run",value:function(t,n,e){var i=this;this.progress||(this.props={x:t,y:n},this.options=e,this.easing=o(e.easing)?e.easing:Et[e.easing.replace("ease","")],this.progress=!0,setTimeout(function(){i.startProps={x:I(i.el,"x"),y:I(i.el,"y")},i.rafId=zt(function(t){return i._loop(t)})},this.options.delay))}},{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this.options.complete;this.startTime=null,this.progress=!1,Mt(this.rafId),t&&(x(this.el,this.props.x,"x"),x(this.el,this.props.y,"y")),o(n)&&(n.call(this),this.options.complete=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,o=this.props,i=this.options,r=this.startTime,l=this.startProps,u=this.easing,a=i.duration,s=i.step,h={},f=t-r,p=yt(1,vt(f/a,0));c(o,function(t,n){var e=l[n],o=t-e;if(0===o)return!0;var i=u(p,a*p,0,1,a);h[n]=gt(e+o*i)}),c(h,function(t,n){x(e,t,n)}),f<=a?(s.call(this,p,h),this.rafId=zt(function(t){return n._loop(t)})):this.stop(!0)}}]),t}(),Pt=function(){return"onwheel"in _t?"wheel":"onmousewheel"in _t?"mousewheel":"DOMMouseScroll"}(),Qt=Pt+", 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]?arguments[1]:"body, html";mt(this,t),this.options=s({},t.defaults,n),this.container=this.getContainer(e),null==this.container?(this.header=null,this.tween=null,/comp|inter|loaded/.test(_t.readyState)?this.log('Not found scrollable container. => "'+e+'"'):this.log("Should be initialize later than DOMContentLoaded.")):(this.header=p(this.options.header),this.tween=new Dt(this.container),this._trigger=null,this._shouldCallCancelScroll=!1,this.bindContainerClick())}return kt(t,[{key:"log",value:function(t){this.options.outputLog&&f("[SweetScroll] "+t)}},{key:"getScrollOffset",value:function(t,n){var o=this.container,i=this.header,r=this.parseCoodinate(n.offset),l=this.parseCoodinate(t);if(!l&&e(t))if("#"===t)l={top:0,left:0};else{var u=p(t),a=L(u,o);if(!a)return;l=a}return l?(r&&(l.top+=r.top,l.left+=r.left),i&&(l.top=vt(0,l.top-w(i).height)),l):null}},{key:"normalizeScrollOffset",value:function(t,n){var e=this.container,o=s({},t),i=_(e),r=i.viewport,l=i.size;return o.top=n.verticalScroll?vt(0,yt(l.height-r.height,o.top)):I(e,"y"),o.left=n.horizontalScroll?vt(0,yt(l.width-r.width,o.left)):I(e,"x"),o}},{key:"to",value:function(t){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.container,r=s({},this.options,o),l=this._trigger,u=e(t)&&/^#/.test(t)?t:null;if(this._options=r,this._trigger=null,this._shouldCallCancelScroll=!1,this.stop(),!i)return this.log("Not found container element.");var a=this.getScrollOffset(t,r);return a?this.hook(r,"beforeScroll",a,l)===!1?void(this._options=null):(a=this.normalizeScrollOffset(a,r),this.tween.run(a.left,a.top,{duration:r.duration,delay:r.delay,easing:r.easing,complete:function(){null!=u&&u!==Ot.location.hash&&n.updateURLHash(u,r.updateURL),n.unbindContainerStop(),n._options=null,n._shouldCallCancelScroll?n.hook(r,"cancelScroll"):n.hook(r,"afterScroll",a,l),n.hook(r,"completeScroll",n._shouldCallCancelScroll)},step:function(t,e){n.hook(r,"stepScroll",t,e)}}),void this.bindContainerStop()):this.log("Invalid parameter of distance. => "+t)}},{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 Element){var e=L(t,this.container);this.to(e,s({},n))}else this.log("Invalid parameter.")}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.container?(this._stopScrollListener&&(this._shouldCallCancelScroll=!0),this.tween.stop(t)):this.log("Not found scrollable container.")}},{key:"update",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.container?(this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.options=s({},this.options,t),this.header=p(this.options.header),this.bindContainerClick()):this.log("Not found scrollable container.")}},{key:"destroy",value:function(){this.container?(this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.container=null,this.header=null,this.tween=null):this.log("Not found scrollable container.")}},{key:"beforeScroll",value:function(t,n){return!0}},{key:"cancelScroll",value:function(){}},{key:"afterScroll",value:function(t,n){}},{key:"completeScroll",value:function(t){}},{key:"stepScroll",value:function(t,n){}},{key:"parseCoodinate",value:function(t){var n=this._options?this._options.verticalScroll:this.options.verticalScroll,o={top:0,left:0};if(a(t,"top")||a(t,"left"))o=s(o,t);else if(i(t))2===t.length?(o.top=t[0],o.left=t[1]):(o.top=n?t[0]:0,o.left=n?0:t[0]);else if(l(t))o.top=n?t:0,o.left=n?0:t;else{if(!e(t))return null;var r=h(t);if(/^\d+,\d+$/.test(r))r=r.split(","),o.top=r[0],o.left=r[1];else if(/^(top|left):\d+,?(?:(top|left):\d+)?$/.test(r)){var u=r.match(/top:(\d+)/),c=r.match(/left:(\d+)/);o.top=u?u[1]:0,o.left=c?c[1]:0}else{if(!this.container||!/^(\+|-)=(\d+)$/.test(r))return null;var f=I(this.container,n?"y":"x"),p=r.match(/^(\+|-)=(\d+)$/),d=p[1],v=parseInt(p[2],10);"+"===d?(o.top=n?f+v:0,o.left=n?0:f+v):(o.top=n?f-v:0,o.left=n?0:f-v)}}return o.top=parseInt(o.top,10),o.left=parseInt(o.left,10),o}},{key:"updateURLHash",value:function(t,n){Lt&&n&&Ot.history["replace"===n?"replaceState":"pushState"](null,null,t)}},{key:"getContainer",value:function(t){var n=this.options,e=n.verticalScroll,o=n.horizontalScroll,i=null;return e&&(i=m(t,"y")),!i&&o&&(i=m(t,"x")),i}},{key:"bindContainerClick",value:function(){var t=this.container;t&&(this._containerClickListener=this.handleContainerClick.bind(this),E(t,"click",this._containerClickListener))}},{key:"unbindContainerClick",value:function(){var t=this.container;t&&this._containerClickListener&&(A(t,"click",this._containerClickListener),this._containerClickListener=null)}},{key:"bindContainerStop",value:function(){var t=this.container;t&&(this._stopScrollListener=this.handleStopScroll.bind(this),E(t,Qt,this._stopScrollListener))}},{key:"unbindContainerStop",value:function(){var t=this.container;t&&this._stopScrollListener&&(A(t,Qt,this._stopScrollListener),this._stopScrollListener=null)}},{key:"hook",value:function(t,n){for(var e=t[n],i=arguments.length,r=Array(i>2?i-2:0),l=2;l<i;l++)r[l-2]=arguments[l];if(o(e)){var u=e.apply(this,r);if("undefined"==typeof u)return u}return this[n].apply(this,r)}},{key:"handleStopScroll",value:function(t){var n=this._options?this._options.stopScroll:this.options.stopScroll;n?this.stop():t.preventDefault()}},{key:"handleContainerClick",value:function(t){for(var n=this.options,e=t.target;e&&e!==_t;e=e.parentNode)if(v(e,n.trigger)){var o=e.getAttribute("data-scroll"),i=this.parseDataOptions(e),r=o||e.getAttribute("href");n=s({},n,i),n.preventDefault&&t.preventDefault(),n.stopPropagation&&t.stopPropagation(),this._trigger=e,n.horizontalScroll&&n.verticalScroll?this.to(r,n):n.verticalScroll?this.toTop(r,n):n.horizontalScroll&&this.toLeft(r,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,updateURL:!1,preventDefault:!0,stopPropagation:!0,outputLog:!1,beforeScroll:null,afterScroll:null,cancelScroll:null,completeScroll:null,stepScroll:null},Wt});
!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?"":"object"===("undefined"==typeof t?"undefined":St(t))||"function"==typeof t?wt[Object.prototype.toString.call(t)]||"object":"undefined"==typeof t?"undefined":St(t)}function n(n){return"number"===t(n)}function e(n){return"string"===t(n)}function o(n){return"function"===t(n)}function i(t){return Array.isArray(t)}function r(t){var e=null==t?null:t.length;return n(e)&&e>=0&&e<=bt}function l(t){return!i(t)&&t-parseFloat(t)+1>=0}function u(n){return!i(n)&&"object"===t(n)}function a(t,n){return t&&t.hasOwnProperty(n)}function c(t,n,e){if(null==t)return t;var o=e||t;if(u(t)){for(var i in t)if(a(t,i)&&n.call(o,t[i],i)===!1)break}else if(r(t))for(var l=0;l<t.length&&n.call(o,t[l],l)!==!1;l++);return t}function s(t){for(var n=arguments.length,e=Array(n>1?n-1:0),o=1;o<n;o++)e[o-1]=arguments[o];return c(e,function(n){c(n,function(n,e){t[e]=n})}),t}function h(t){return t.replace(/\s*/g,"")||""}function f(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw new Error(t)}catch(t){}}function p(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t)return(null==n?_t:n).querySelector(t)}function d(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t)return(null==n?_t:n).querySelectorAll(t)}function v(t,n){for(var e=(t.document||t.ownerDocument).querySelectorAll(n),o=e.length;--o>=0&&e.item(o)!==t;);return o>-1}function y(t){return t===_t.documentElement||t===_t.body}function g(){var t=Ot.outerWidth,n=Ot.innerWidth;return t?t/n:1}function S(t){for(var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",e=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=xt[n],i=t instanceof Element?[t]:d(t),r=[],l=_t.createElement("div"),u=0;u<i.length;u++){var a=i[u];if(a[o]>0?r.push(a):(l.style.width=a.clientWidth+1+"px",l.style.height=a.clientHeight+1+"px",a.appendChild(l),a[o]=1.5/g(),a[o]>0&&r.push(a),a[o]=0,a.removeChild(l)),!e&&r.length>0)break}return r}function m(t,n){var e=S(t,n,!1);return e.length>=1?e[0]:null}function k(t){return null!=t&&t===t.window?t:9===t.nodeType&&t.defaultView}function b(t){return vt(t.scrollHeight,t.clientHeight,t.offsetHeight)}function C(t){return vt(t.scrollWidth,t.clientWidth,t.offsetWidth)}function w(t){return{width:C(t),height:b(t)}}function O(){return{width:vt(C(_t.body),C(_t.documentElement)),height:vt(b(_t.body),b(_t.documentElement))}}function _(t){return y(t)?{viewport:{width:yt(Ot.innerWidth,_t.documentElement.clientWidth),height:Ot.innerHeight},size:O()}:{viewport:{width:t.clientWidth,height:t.clientHeight},size:w(t)}}function x(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y",e=k(t);return e?e[It[n]]:t[xt[n]]}function I(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"y",o=k(t),i="y"===e;o?o.scrollTo(i?o[It.x]:n,i?n:o[It.y]):t[xt[e]]=n}function L(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t||t&&!t.getClientRects().length)return{top:0,left:0};var e=t.getBoundingClientRect();if(e.width||e.height){var o={},i=null;if(null==n||y(n))i=t.ownerDocument.documentElement,o.top=Ot.pageYOffset,o.left=Ot.pageXOffset;else{i=n;var r=i.getBoundingClientRect();o.top=r.top*-1+i.scrollTop,o.left=r.left*-1+i.scrollLeft}return{top:e.top+o.top-i.clientTop,left:e.left+o.left-i.clientLeft}}return e}function E(t,n,e){var o=n.split(",");o.forEach(function(n){t.addEventListener(n.trim(),e,!1)})}function A(t,n,e){var o=n.split(",");o.forEach(function(n){t.removeEventListener(n.trim(),e,!1)})}function M(t){return t}function T(t,n,e,o,i){return o*(n/=i)*n+e}function z(t,n,e,o,i){return-o*(n/=i)*(n-2)+e}function P(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n+e:-o/2*(--n*(n-2)-1)+e}function j(t,n,e,o,i){return o*(n/=i)*n*n+e}function q(t,n,e,o,i){return o*((n=n/i-1)*n*n+1)+e}function D(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n+e:o/2*((n-=2)*n*n+2)+e}function Q(t,n,e,o,i){return o*(n/=i)*n*n*n+e}function W(t,n,e,o,i){return-o*((n=n/i-1)*n*n*n-1)+e}function B(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n*n+e:-o/2*((n-=2)*n*n*n-2)+e}function R(t,n,e,o,i){return o*(n/=i)*n*n*n*n+e}function H(t,n,e,o,i){return o*((n=n/i-1)*n*n*n*n+1)+e}function N(t,n,e,o,i){return(n/=i/2)<1?o/2*n*n*n*n*n+e:o/2*((n-=2)*n*n*n*n+2)+e}function F(t,n,e,o,i){return-o*at(n/i*(dt/2))+o+e}function U(t,n,e,o,i){return o*ct(n/i*(dt/2))+e}function $(t,n,e,o,i){return-o/2*(at(dt*n/i)-1)+e}function X(t,n,e,o,i){return 0===n?e:o*st(2,10*(n/i-1))+e}function Y(t,n,e,o,i){return n===i?e+o:o*(-st(2,-10*n/i)+1)+e}function J(t,n,e,o,i){return 0===n?e:n===i?e+o:(n/=i/2)<1?o/2*st(2,10*(n-1))+e:o/2*(-st(2,-10*--n)+2)+e}function V(t,n,e,o,i){return-o*(ft(1-(n/=i)*n)-1)+e}function G(t,n,e,o,i){return o*ft(1-(n=n/i-1)*n)+e}function K(t,n,e,o,i){return(n/=i/2)<1?-o/2*(ft(1-n*n)-1)+e:o/2*(ft(1-(n-=2)*n)+1)+e}function Z(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:1===(n/=i)?e+o:(l||(l=.3*i),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),-(u*st(2,10*(n-=1))*ct((n*i-r)*(2*dt)/l))+e)}function tt(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:1===(n/=i)?e+o:(l||(l=.3*i),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),u*st(2,-10*n)*ct((n*i-r)*(2*dt)/l)+o+e)}function nt(t,n,e,o,i){var r=1.70158,l=0,u=o;return 0===n?e:2===(n/=i/2)?e+o:(l||(l=i*(.3*1.5)),u<ht(o)?(u=o,r=l/4):r=l/(2*dt)*pt(o/u),n<1?-.5*(u*st(2,10*(n-=1))*ct((n*i-r)*(2*dt)/l))+e:u*st(2,-10*(n-=1))*ct((n*i-r)*(2*dt)/l)*.5+o+e)}function et(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return o*(n/=i)*n*((r+1)*n-r)+e}function ot(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return o*((n=n/i-1)*n*((r+1)*n+r)+1)+e}function it(t,n,e,o,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1.70158;return(n/=i/2)<1?o/2*(n*n*(((r*=1.525)+1)*n-r))+e:o/2*((n-=2)*n*(((r*=1.525)+1)*n+r)+2)+e}function rt(t,n,e,o,i){return(n/=i)<1/2.75?o*(7.5625*n*n)+e:n<2/2.75?o*(7.5625*(n-=1.5/2.75)*n+.75)+e:n<2.5/2.75?o*(7.5625*(n-=2.25/2.75)*n+.9375)+e:o*(7.5625*(n-=2.625/2.75)*n+.984375)+e}function lt(t,n,e,o,i){return o-rt(t,i-n,0,o,i)+e}function ut(t,n,e,o,i){return n<i/2?.5*lt(t,2*n,0,o,i)+e:.5*rt(t,2*n-i,0,o,i)+.5*o+e}var at=Math.cos,ct=Math.sin,st=Math.pow,ht=Math.abs,ft=Math.sqrt,pt=Math.asin,dt=Math.PI,vt=Math.max,yt=Math.min,gt=Math.round,St="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},mt=(function(){function t(t){this.value=t}function n(n){function e(t,n){return new Promise(function(e,i){var u={key:t,arg:n,resolve:e,reject:i,next:null};l?l=l.next=u:(r=l=u,o(t,n))})}function o(e,r){try{var l=n[e](r),u=l.value;u instanceof t?Promise.resolve(u.value).then(function(t){o("next",t)},function(t){o("throw",t)}):i(l.done?"return":"normal",l.value)}catch(t){i("throw",t)}}function i(t,n){switch(t){case"return":r.resolve({value:n,done:!0});break;case"throw":r.reject(n);break;default:r.resolve({value:n,done:!1})}r=r.next,r?o(r.key,r.arg):l=null}var r,l;this._invoke=e,"function"!=typeof n.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(n.prototype[Symbol.asyncIterator]=function(){return this}),n.prototype.next=function(t){return this._invoke("next",t)},n.prototype.throw=function(t){return this._invoke("throw",t)},n.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new n(t.apply(this,arguments))}},await:function(n){return new t(n)}}}(),function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}),kt=function(){function t(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(n,e,o){return e&&t(n.prototype,e),o&&t(n,o),n}}(),bt=st(2,53)-1,Ct=["Boolean","Number","String","Function","Array","Object"],wt={};Ct.forEach(function(t){wt["[object "+t+"]"]=t.toLowerCase()});for(var Ot=window,_t=document,xt={y:"scrollTop",x:"scrollLeft"},It={y:"pageYOffset",x:"pageXOffset"},Lt=(function(){var t=navigator.userAgent;return(t.indexOf("Android 2.")===-1&&t.indexOf("Android 4.0")===-1||t.indexOf("Mobile Safari")===-1||t.indexOf("Chrome")!==-1||t.indexOf("Windows Phone")!==-1)&&(Ot.history&&"pushState"in Ot.history&&"file:"!==Ot.location.protocol)}()),Et=Object.freeze({linear:M,InQuad:T,OutQuad:z,InOutQuad:P,InCubic:j,OutCubic:q,InOutCubic:D,InQuart:Q,OutQuart:W,InOutQuart:B,InQuint:R,OutQuint:H,InOutQuint:N,InSine:F,OutSine:U,InOutSine:$,InExpo:X,OutExpo:Y,InOutExpo:J,InCirc:V,OutCirc:G,InOutCirc:K,InElastic:Z,OutElastic:tt,InOutElastic:nt,InBack:et,OutBack:ot,InOutBack:it,OutBounce:rt,InBounce:lt,InOutBounce:ut}),At=["ms","moz","webkit"],Mt=0,Tt=Ot.requestAnimationFrame,zt=Ot.cancelAnimationFrame,Pt=0;Pt<At.length&&!Tt;++Pt)Tt=Ot[At[Pt]+"RequestAnimationFrame"],zt=Ot[At[Pt]+"CancelAnimationFrame"]||Ot[At[Pt]+"CancelRequestAnimationFrame"];Tt||(Tt=function(t){var n=Date.now(),e=vt(0,16-(n-Mt)),o=setTimeout(function(){t(n+e)},e);return Mt=n+e,o}),zt||(zt=function(t){clearTimeout(t)});var jt=function(){function t(n){mt(this,t),this.el=n,this.props={},this.options={},this.progress=!1,this.easing=null,this.startTime=null,this.rafId=null}return kt(t,[{key:"run",value:function(t,n,e){var i=this;this.progress||(this.props={x:t,y:n},this.options=e,this.easing=o(e.easing)?e.easing:Et[e.easing.replace("ease","")],this.progress=!0,setTimeout(function(){i.startProps=i.calcStartProps(t,n),i.rafId=Tt(function(t){return i._loop(t)})},this.options.delay))}},{key:"stop",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=this.options.complete;this.startTime=null,this.progress=!1,zt(this.rafId),t&&(I(this.el,this.props.x,"x"),I(this.el,this.props.y,"y")),o(n)&&(n.call(this),this.options.complete=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,o=this.props,i=this.options,r=this.startTime,l=this.startProps,u=this.easing,a=i.duration,s=i.step,h={},f=t-r,p=yt(1,vt(f/a,0));c(o,function(t,n){var e=l[n],o=t-e;if(0===o)return!0;var i=u(p,a*p,0,1,a);h[n]=gt(e+o*i)}),c(h,function(t,n){I(e,t,n)}),f<=a?(s.call(this,p,h),this.rafId=Tt(function(t){return n._loop(t)})):this.stop(!0)}},{key:"calcStartProps",value:function(t,n){var e={x:x(this.el,"x"),y:x(this.el,"y")};if(this.options.quickMode){var o=_(this.el),i=o.viewport,r=i.width,l=i.height;ht(e.y-n)>l&&(e.y=e.y>n?n+l:n-l),ht(e.x-t)>r&&(e.x=e.x>t?t+r:t-r)}return e}}]),t}(),qt=function(){return"onwheel"in _t?"wheel":"onmousewheel"in _t?"mousewheel":"DOMMouseScroll"}(),Dt=qt+", touchstart, touchmove",Qt=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"body, html";mt(this,t),this.options=s({},t.defaults,n),this.container=this.getContainer(e),null==this.container?(this.header=null,this.tween=null,/comp|inter|loaded/.test(_t.readyState)?this.log('Not found scrollable container. => "'+e+'"'):this.log("Should be initialize later than DOMContentLoaded.")):(this.header=p(this.options.header),this.tween=new jt(this.container),this._trigger=null,this._shouldCallCancelScroll=!1,this.bindContainerClick())}return kt(t,[{key:"log",value:function(t){this.options.outputLog&&f("[SweetScroll] "+t)}},{key:"getScrollOffset",value:function(t,n){var o=this.container,i=this.header,r=this.parseCoodinate(n.offset),l=this.parseCoodinate(t);if(!l&&e(t))if("#"===t)l={top:0,left:0};else{var u=p(t),a=L(u,o);if(!a)return;l=a}return l?(r&&(l.top+=r.top,l.left+=r.left),i&&(l.top=vt(0,l.top-w(i).height)),l):null}},{key:"normalizeScrollOffset",value:function(t,n){var e=this.container,o=s({},t),i=_(e),r=i.viewport,l=i.size;return o.top=n.verticalScroll?vt(0,yt(l.height-r.height,o.top)):x(e,"y"),o.left=n.horizontalScroll?vt(0,yt(l.width-r.width,o.left)):x(e,"x"),o}},{key:"to",value:function(t){var n=this,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.container,r=s({},this.options,o),l=this._trigger,u=e(t)&&/^#/.test(t)?t:null;if(this._options=r,this._trigger=null,this._shouldCallCancelScroll=!1,this.stop(),!i)return this.log("Not found container element.");var a=this.getScrollOffset(t,r);return a?this.hook(r,"beforeScroll",a,l)===!1?void(this._options=null):(a=this.normalizeScrollOffset(a,r),this.tween.run(a.left,a.top,{duration:r.duration,delay:r.delay,easing:r.easing,quickMode:r.quickMode,complete:function(){null!=u&&u!==Ot.location.hash&&n.updateURLHash(u,r.updateURL),n.unbindContainerStop(),n._options=null,n._shouldCallCancelScroll?n.hook(r,"cancelScroll"):n.hook(r,"afterScroll",a,l),n.hook(r,"completeScroll",n._shouldCallCancelScroll)},step:function(t,e){n.hook(r,"stepScroll",t,e)}}),void this.bindContainerStop()):this.log("Invalid parameter of distance. => "+t)}},{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 Element){var e=L(t,this.container);this.to(e,s({},n))}else this.log("Invalid parameter.")}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.container?(this._stopScrollListener&&(this._shouldCallCancelScroll=!0),this.tween.stop(t)):this.log("Not found scrollable container.")}},{key:"update",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.container?(this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.options=s({},this.options,t),this.header=p(this.options.header),this.bindContainerClick()):this.log("Not found scrollable container.")}},{key:"destroy",value:function(){this.container?(this.stop(),this.unbindContainerClick(),this.unbindContainerStop(),this.container=null,this.header=null,this.tween=null):this.log("Not found scrollable container.")}},{key:"beforeScroll",value:function(t,n){return!0}},{key:"cancelScroll",value:function(){}},{key:"afterScroll",value:function(t,n){}},{key:"completeScroll",value:function(t){}},{key:"stepScroll",value:function(t,n){}},{key:"parseCoodinate",value:function(t){var n=this._options?this._options.verticalScroll:this.options.verticalScroll,o={top:0,left:0};if(a(t,"top")||a(t,"left"))o=s(o,t);else if(i(t))2===t.length?(o.top=t[0],o.left=t[1]):(o.top=n?t[0]:0,o.left=n?0:t[0]);else if(l(t))o.top=n?t:0,o.left=n?0:t;else{if(!e(t))return null;var r=h(t);if(/^\d+,\d+$/.test(r))r=r.split(","),o.top=r[0],o.left=r[1];else if(/^(top|left):\d+,?(?:(top|left):\d+)?$/.test(r)){var u=r.match(/top:(\d+)/),c=r.match(/left:(\d+)/);o.top=u?u[1]:0,o.left=c?c[1]:0}else{if(!this.container||!/^(\+|-)=(\d+)$/.test(r))return null;var f=x(this.container,n?"y":"x"),p=r.match(/^(\+|-)=(\d+)$/),d=p[1],v=parseInt(p[2],10);"+"===d?(o.top=n?f+v:0,o.left=n?0:f+v):(o.top=n?f-v:0,o.left=n?0:f-v)}}return o.top=parseInt(o.top,10),o.left=parseInt(o.left,10),o}},{key:"updateURLHash",value:function(t,n){Lt&&n&&Ot.history["replace"===n?"replaceState":"pushState"](null,null,t)}},{key:"getContainer",value:function(t){var n=this.options,e=n.verticalScroll,o=n.horizontalScroll,i=null;return e&&(i=m(t,"y")),!i&&o&&(i=m(t,"x")),i}},{key:"bindContainerClick",value:function(){var t=this.container;t&&(this._containerClickListener=this.handleContainerClick.bind(this),E(t,"click",this._containerClickListener))}},{key:"unbindContainerClick",value:function(){var t=this.container;t&&this._containerClickListener&&(A(t,"click",this._containerClickListener),this._containerClickListener=null)}},{key:"bindContainerStop",value:function(){var t=this.container;t&&(this._stopScrollListener=this.handleStopScroll.bind(this),E(t,Dt,this._stopScrollListener))}},{key:"unbindContainerStop",value:function(){var t=this.container;t&&this._stopScrollListener&&(A(t,Dt,this._stopScrollListener),this._stopScrollListener=null)}},{key:"hook",value:function(t,n){for(var e=t[n],i=arguments.length,r=Array(i>2?i-2:0),l=2;l<i;l++)r[l-2]=arguments[l];if(o(e)){var u=e.apply(this,r);if("undefined"==typeof u)return u}return this[n].apply(this,r)}},{key:"handleStopScroll",value:function(t){var n=this._options?this._options.stopScroll:this.options.stopScroll;n?this.stop():t.preventDefault()}},{key:"handleContainerClick",value:function(t){for(var n=this.options,e=t.target;e&&e!==_t;e=e.parentNode)if(v(e,n.trigger)){var o=e.getAttribute("data-scroll"),i=this.parseDataOptions(e),r=o||e.getAttribute("href");n=s({},n,i),n.preventDefault&&t.preventDefault(),n.stopPropagation&&t.stopPropagation(),this._trigger=e,n.horizontalScroll&&n.verticalScroll?this.to(r,n):n.verticalScroll?this.toTop(r,n):n.horizontalScroll&&this.toLeft(r,n)}}},{key:"parseDataOptions",value:function(t){var n=t.getAttribute("data-scroll-options");return n?JSON.parse(n):{}}}]),t}();return Qt.defaults={trigger:"[data-scroll]",header:"[data-scroll-header]",duration:1e3,delay:0,easing:"easeOutQuint",offset:0,verticalScroll:!0,horizontalScroll:!1,stopScroll:!0,updateURL:!1,preventDefault:!0,stopPropagation:!0,outputLog:!1,quickMode:!1,beforeScroll:null,afterScroll:null,cancelScroll:null,completeScroll:null,stepScroll:null},Qt});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc