diff --git a/dist/bscroll.esm.js b/dist/bscroll.esm.js index 3b6687c6..521c18b0 100644 --- a/dist/bscroll.esm.js +++ b/dist/bscroll.esm.js @@ -1,5 +1,5 @@ /*! - * better-normal-scroll v1.12.6 + * better-normal-scroll v1.13.0 * (c) 2016-2018 ustbhuangyi * Released under the MIT License. */ @@ -227,16 +227,20 @@ function offsetToBody(el) { }; } +var cssVendor = vendor && vendor !== 'standard' ? '-' + vendor.toLowerCase() + '-' : ''; + var transform = prefixStyle('transform'); +var transition = prefixStyle('transition'); var hasPerspective = inBrowser && prefixStyle('perspective') in elementStyle; // fix issue #361 var hasTouch = inBrowser && ('ontouchstart' in window || isWeChatDevTools); var hasTransform = transform !== false; -var hasTransition = inBrowser && prefixStyle('transition') in elementStyle; +var hasTransition = inBrowser && transition in elementStyle; var style = { transform: transform, + transition: transition, transitionTimingFunction: prefixStyle('transitionTimingFunction'), transitionDuration: prefixStyle('transitionDuration'), transitionDelay: prefixStyle('transitionDelay'), @@ -2976,10 +2980,33 @@ function InfiniteScroller(scroller, options) { this.scroller.on('resize', function () { _this.onResize(); }); + this.scroller.on('destroy', function () { + _this.destroy(); + }); - this.onResize(); + // wait scroll core init + setTimeout(function () { + _this.onResize(); + }); } +InfiniteScroller.prototype.destroy = function () { + var _this2 = this; + + this.items.forEach(function (item) { + if (item.node) { + _this2.scrollerEl.removeChild(item.node); + item.node = null; + } + }); + this.scroller.infiniteScroller = null; + this.scroller = null; + this.wrapperEl = null; + this.scrollerEl = null; + this.items = null; + this.tombstones = null; +}; + InfiniteScroller.prototype.onScroll = function () { var scrollTop = -this.scroller.y; var delta = scrollTop - this.anchorScrollTop; @@ -2993,7 +3020,7 @@ InfiniteScroller.prototype.onScroll = function () { } this.anchorScrollTop = scrollTop; - var lastScreenItem = this._calculateAnchoredItem(this.anchorItem, this.wrapperEl.offsetHeight); + var lastScreenItem = this._calculateAnchoredItem(this.anchorItem, this.scroller.wrapperHeight); var start = this.anchorItem.index; var end = lastScreenItem.index; @@ -3034,7 +3061,7 @@ InfiniteScroller.prototype.fill = function (start, end) { }; InfiniteScroller.prototype.maybeRequestContent = function () { - var _this2 = this; + var _this3 = this; if (this.requestInProgress || !this.hasMore) { return; @@ -3045,24 +3072,24 @@ InfiniteScroller.prototype.maybeRequestContent = function () { } this.requestInProgress = true; this.options.fetch(itemsNeeded).then(function (items) { - _this2.requestInProgress = false; + _this3.requestInProgress = false; if (items) { - _this2.addContent(items); + _this3.addContent(items); } else { - _this2.hasMore = false; - var tombstoneLen = _this2._removeTombstones(); + _this3.hasMore = false; + var tombstoneLen = _this3._removeTombstones(); var curPos = 0; - if (_this2.anchorItem.index <= _this2.items.length) { - curPos = _this2._fixScrollPosition(); - _this2._setupAnimations({}, curPos); - _this2.scroller.resetPosition(_this2.scroller.options.bounceTime); + if (_this3.anchorItem.index <= _this3.items.length) { + curPos = _this3._fixScrollPosition(); + _this3._setupAnimations({}, curPos); + _this3.scroller.resetPosition(_this3.scroller.options.bounceTime); } else { - _this2.anchorItem.index -= tombstoneLen; - curPos = _this2._fixScrollPosition(); - _this2._setupAnimations({}, curPos); - _this2.scroller.stop(); - _this2.scroller.resetPosition(); - _this2.onScroll(); + _this3.anchorItem.index -= tombstoneLen; + curPos = _this3._fixScrollPosition(); + _this3._setupAnimations({}, curPos); + _this3.scroller.stop(); + _this3.scroller.resetPosition(); + _this3.onScroll(); } } }); @@ -3171,10 +3198,12 @@ InfiniteScroller.prototype._cleanupUnusedNodes = function (unusedNodes) { InfiniteScroller.prototype._cacheNodeSize = function () { for (var i = this.firstAttachedItem; i < this.lastAttachedItem; i++) { + var item = this.items[i]; // Only cache the height if we have the real contents, not a placeholder. - if (this.items[i].data && !this.items[i].height) { - this.items[i].height = this.items[i].node.offsetHeight; - this.items[i].width = this.items[i].node.offsetWidth; + if (item.data && !item.height) { + var isTombstone = isTombstoneNode(item.node); + item.height = isTombstone ? this.tombstoneHeight : item.node.offsetHeight; + item.width = isTombstone ? this.tombstoneWidth : item.node.offsetWidth; } } }; @@ -3198,44 +3227,44 @@ InfiniteScroller.prototype._fixScrollPosition = function () { }; InfiniteScroller.prototype._setupAnimations = function (tombstoneAnimations, curPos) { - var _this3 = this; + var _this4 = this; for (var i in tombstoneAnimations) { var animation = tombstoneAnimations[i]; - this.items[i].node.style.transform = 'translateY(' + (this.anchorScrollTop + animation[1]) + 'px) scale(' + this.tombstoneWidth / this.items[i].width + ', ' + this.tombstoneHeight / this.items[i].height + ')'; + this.items[i].node.style[style.transform] = 'translateY(' + (this.anchorScrollTop + animation[1]) + 'px) scale(' + this.tombstoneWidth / this.items[i].width + ', ' + this.tombstoneHeight / this.items[i].height + ')'; // Call offsetTop on the nodes to be animated to force them to apply current transforms. /* eslint-disable no-unused-expressions */ this.items[i].node.offsetTop; animation[0].offsetTop; - this.items[i].node.style.transition = 'transform ' + ANIMATION_DURATION_MS + 'ms'; + this.items[i].node.style[style.transition] = cssVendor + 'transform ' + ANIMATION_DURATION_MS + 'ms'; } for (var _i2 = this.firstAttachedItem; _i2 < this.lastAttachedItem; _i2++) { var _animation = tombstoneAnimations[_i2]; if (_animation) { var tombstoneNode = _animation[0]; - tombstoneNode.style.transition = 'transform ' + ANIMATION_DURATION_MS + 'ms, opacity ' + ANIMATION_DURATION_MS + 'ms'; - tombstoneNode.style.transform = 'translateY(' + curPos + 'px) scale(' + this.items[_i2].width / this.tombstoneWidth + ', ' + this.items[_i2].height / this.tombstoneHeight + ')'; + tombstoneNode.style[style.transition] = cssVendor + 'transform ' + ANIMATION_DURATION_MS + 'ms, opacity ' + ANIMATION_DURATION_MS + 'ms'; + tombstoneNode.style[style.transform] = 'translateY(' + curPos + 'px) scale(' + this.items[_i2].width / this.tombstoneWidth + ', ' + this.items[_i2].height / this.tombstoneHeight + ')'; tombstoneNode.style.opacity = 0; } if (curPos !== this.items[_i2].top) { if (!_animation) { - this.items[_i2].node.style.transition = ''; + this.items[_i2].node.style[style.transition] = ''; } - this.items[_i2].node.style.transform = 'translateY(' + curPos + 'px)'; + this.items[_i2].node.style[style.transform] = 'translateY(' + curPos + 'px)'; } this.items[_i2].top = curPos; curPos += this.items[_i2].height || this.tombstoneHeight; } - this.scroller.maxScrollY = -(curPos - this.wrapperEl.offsetHeight + (this.hasMore ? DEFAULT_SCROLL_RUNWAY : 0)); + this.scroller.maxScrollY = -(curPos - this.scroller.wrapperHeight + (this.hasMore ? DEFAULT_SCROLL_RUNWAY : 0)); setTimeout(function () { for (var _i3 in tombstoneAnimations) { var _animation2 = tombstoneAnimations[_i3]; _animation2[0].style.display = 'none'; // Tombstone can be recycled now. - _this3.tombstones.push(_animation2[0]); + _this4.tombstones.push(_animation2[0]); } }, ANIMATION_DURATION_MS); }; @@ -3245,8 +3274,8 @@ InfiniteScroller.prototype._getTombStone = function () { if (tombstone) { tombstone.style.display = ''; tombstone.style.opacity = 1; - tombstone.style.transform = ''; - tombstone.style.transition = ''; + tombstone.style[style.transform] = ''; + tombstone.style[style.transition] = ''; return tombstone; } return this.options.createTombstone(); @@ -3321,6 +3350,6 @@ mouseWheelMixin(BScroll); zoomMixin(BScroll); infiniteMixin(BScroll); -BScroll.Version = '1.12.6'; +BScroll.Version = '1.13.0'; export default BScroll; diff --git a/dist/bscroll.js b/dist/bscroll.js index 4b516c13..7b88dd0a 100644 --- a/dist/bscroll.js +++ b/dist/bscroll.js @@ -1,5 +1,5 @@ /*! - * better-normal-scroll v1.12.6 + * better-normal-scroll v1.13.0 * (c) 2016-2018 ustbhuangyi * Released under the MIT License. */ @@ -233,16 +233,20 @@ function offsetToBody(el) { }; } +var cssVendor = vendor && vendor !== 'standard' ? '-' + vendor.toLowerCase() + '-' : ''; + var transform = prefixStyle('transform'); +var transition = prefixStyle('transition'); var hasPerspective = inBrowser && prefixStyle('perspective') in elementStyle; // fix issue #361 var hasTouch = inBrowser && ('ontouchstart' in window || isWeChatDevTools); var hasTransform = transform !== false; -var hasTransition = inBrowser && prefixStyle('transition') in elementStyle; +var hasTransition = inBrowser && transition in elementStyle; var style = { transform: transform, + transition: transition, transitionTimingFunction: prefixStyle('transitionTimingFunction'), transitionDuration: prefixStyle('transitionDuration'), transitionDelay: prefixStyle('transitionDelay'), @@ -2982,10 +2986,33 @@ function InfiniteScroller(scroller, options) { this.scroller.on('resize', function () { _this.onResize(); }); + this.scroller.on('destroy', function () { + _this.destroy(); + }); - this.onResize(); + // wait scroll core init + setTimeout(function () { + _this.onResize(); + }); } +InfiniteScroller.prototype.destroy = function () { + var _this2 = this; + + this.items.forEach(function (item) { + if (item.node) { + _this2.scrollerEl.removeChild(item.node); + item.node = null; + } + }); + this.scroller.infiniteScroller = null; + this.scroller = null; + this.wrapperEl = null; + this.scrollerEl = null; + this.items = null; + this.tombstones = null; +}; + InfiniteScroller.prototype.onScroll = function () { var scrollTop = -this.scroller.y; var delta = scrollTop - this.anchorScrollTop; @@ -2999,7 +3026,7 @@ InfiniteScroller.prototype.onScroll = function () { } this.anchorScrollTop = scrollTop; - var lastScreenItem = this._calculateAnchoredItem(this.anchorItem, this.wrapperEl.offsetHeight); + var lastScreenItem = this._calculateAnchoredItem(this.anchorItem, this.scroller.wrapperHeight); var start = this.anchorItem.index; var end = lastScreenItem.index; @@ -3040,7 +3067,7 @@ InfiniteScroller.prototype.fill = function (start, end) { }; InfiniteScroller.prototype.maybeRequestContent = function () { - var _this2 = this; + var _this3 = this; if (this.requestInProgress || !this.hasMore) { return; @@ -3051,24 +3078,24 @@ InfiniteScroller.prototype.maybeRequestContent = function () { } this.requestInProgress = true; this.options.fetch(itemsNeeded).then(function (items) { - _this2.requestInProgress = false; + _this3.requestInProgress = false; if (items) { - _this2.addContent(items); + _this3.addContent(items); } else { - _this2.hasMore = false; - var tombstoneLen = _this2._removeTombstones(); + _this3.hasMore = false; + var tombstoneLen = _this3._removeTombstones(); var curPos = 0; - if (_this2.anchorItem.index <= _this2.items.length) { - curPos = _this2._fixScrollPosition(); - _this2._setupAnimations({}, curPos); - _this2.scroller.resetPosition(_this2.scroller.options.bounceTime); + if (_this3.anchorItem.index <= _this3.items.length) { + curPos = _this3._fixScrollPosition(); + _this3._setupAnimations({}, curPos); + _this3.scroller.resetPosition(_this3.scroller.options.bounceTime); } else { - _this2.anchorItem.index -= tombstoneLen; - curPos = _this2._fixScrollPosition(); - _this2._setupAnimations({}, curPos); - _this2.scroller.stop(); - _this2.scroller.resetPosition(); - _this2.onScroll(); + _this3.anchorItem.index -= tombstoneLen; + curPos = _this3._fixScrollPosition(); + _this3._setupAnimations({}, curPos); + _this3.scroller.stop(); + _this3.scroller.resetPosition(); + _this3.onScroll(); } } }); @@ -3177,10 +3204,12 @@ InfiniteScroller.prototype._cleanupUnusedNodes = function (unusedNodes) { InfiniteScroller.prototype._cacheNodeSize = function () { for (var i = this.firstAttachedItem; i < this.lastAttachedItem; i++) { + var item = this.items[i]; // Only cache the height if we have the real contents, not a placeholder. - if (this.items[i].data && !this.items[i].height) { - this.items[i].height = this.items[i].node.offsetHeight; - this.items[i].width = this.items[i].node.offsetWidth; + if (item.data && !item.height) { + var isTombstone = isTombstoneNode(item.node); + item.height = isTombstone ? this.tombstoneHeight : item.node.offsetHeight; + item.width = isTombstone ? this.tombstoneWidth : item.node.offsetWidth; } } }; @@ -3204,44 +3233,44 @@ InfiniteScroller.prototype._fixScrollPosition = function () { }; InfiniteScroller.prototype._setupAnimations = function (tombstoneAnimations, curPos) { - var _this3 = this; + var _this4 = this; for (var i in tombstoneAnimations) { var animation = tombstoneAnimations[i]; - this.items[i].node.style.transform = 'translateY(' + (this.anchorScrollTop + animation[1]) + 'px) scale(' + this.tombstoneWidth / this.items[i].width + ', ' + this.tombstoneHeight / this.items[i].height + ')'; + this.items[i].node.style[style.transform] = 'translateY(' + (this.anchorScrollTop + animation[1]) + 'px) scale(' + this.tombstoneWidth / this.items[i].width + ', ' + this.tombstoneHeight / this.items[i].height + ')'; // Call offsetTop on the nodes to be animated to force them to apply current transforms. /* eslint-disable no-unused-expressions */ this.items[i].node.offsetTop; animation[0].offsetTop; - this.items[i].node.style.transition = 'transform ' + ANIMATION_DURATION_MS + 'ms'; + this.items[i].node.style[style.transition] = cssVendor + 'transform ' + ANIMATION_DURATION_MS + 'ms'; } for (var _i2 = this.firstAttachedItem; _i2 < this.lastAttachedItem; _i2++) { var _animation = tombstoneAnimations[_i2]; if (_animation) { var tombstoneNode = _animation[0]; - tombstoneNode.style.transition = 'transform ' + ANIMATION_DURATION_MS + 'ms, opacity ' + ANIMATION_DURATION_MS + 'ms'; - tombstoneNode.style.transform = 'translateY(' + curPos + 'px) scale(' + this.items[_i2].width / this.tombstoneWidth + ', ' + this.items[_i2].height / this.tombstoneHeight + ')'; + tombstoneNode.style[style.transition] = cssVendor + 'transform ' + ANIMATION_DURATION_MS + 'ms, opacity ' + ANIMATION_DURATION_MS + 'ms'; + tombstoneNode.style[style.transform] = 'translateY(' + curPos + 'px) scale(' + this.items[_i2].width / this.tombstoneWidth + ', ' + this.items[_i2].height / this.tombstoneHeight + ')'; tombstoneNode.style.opacity = 0; } if (curPos !== this.items[_i2].top) { if (!_animation) { - this.items[_i2].node.style.transition = ''; + this.items[_i2].node.style[style.transition] = ''; } - this.items[_i2].node.style.transform = 'translateY(' + curPos + 'px)'; + this.items[_i2].node.style[style.transform] = 'translateY(' + curPos + 'px)'; } this.items[_i2].top = curPos; curPos += this.items[_i2].height || this.tombstoneHeight; } - this.scroller.maxScrollY = -(curPos - this.wrapperEl.offsetHeight + (this.hasMore ? DEFAULT_SCROLL_RUNWAY : 0)); + this.scroller.maxScrollY = -(curPos - this.scroller.wrapperHeight + (this.hasMore ? DEFAULT_SCROLL_RUNWAY : 0)); setTimeout(function () { for (var _i3 in tombstoneAnimations) { var _animation2 = tombstoneAnimations[_i3]; _animation2[0].style.display = 'none'; // Tombstone can be recycled now. - _this3.tombstones.push(_animation2[0]); + _this4.tombstones.push(_animation2[0]); } }, ANIMATION_DURATION_MS); }; @@ -3251,8 +3280,8 @@ InfiniteScroller.prototype._getTombStone = function () { if (tombstone) { tombstone.style.display = ''; tombstone.style.opacity = 1; - tombstone.style.transform = ''; - tombstone.style.transition = ''; + tombstone.style[style.transform] = ''; + tombstone.style[style.transition] = ''; return tombstone; } return this.options.createTombstone(); @@ -3327,7 +3356,7 @@ mouseWheelMixin(BScroll); zoomMixin(BScroll); infiniteMixin(BScroll); -BScroll.Version = '1.12.6'; +BScroll.Version = '1.13.0'; return BScroll; diff --git a/dist/bscroll.min.js b/dist/bscroll.min.js index c0aecdb4..d4989b53 100644 --- a/dist/bscroll.min.js +++ b/dist/bscroll.min.js @@ -1,6 +1,6 @@ /*! - * better-normal-scroll v1.12.6 + * better-normal-scroll v1.13.0 * (c) 2016-2018 ustbhuangyi * Released under the MIT License. */ -!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):t.BScroll=i()}(this,function(){"use strict";var l=function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,i){var e=[],s=!0,o=!1,n=void 0;try{for(var r,h=t[Symbol.iterator]();!(s=(r=h.next()).done)&&(e.push(r.value),!i||e.length!==i);s=!0);}catch(t){o=!0,n=t}finally{try{!s&&h.return&&h.return()}finally{if(o)throw n}}return e}(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")},c=function(t){if(Array.isArray(t)){for(var i=0,e=Array(t.length);ithis.maxPosY){this.transitionTime(500);var e=Math.max(this.indicatorHeight-3*(t-this.maxPosY),8);this.indicatorStyle.height=e+"px",t=this.maxPosY+this.indicatorHeight-e}else this.indicatorStyle.height=this.indicatorHeight+"px";this.y=t,this.scroller.options.useTransform?this.indicatorStyle[T.transform]="translateY("+t+"px)"+this.scroller.translateZ:this.indicatorStyle.top=t+"px"}else{var s=Math.round(this.sizeRatioX*this.scroller.x);if(s<0){this.transitionTime(500);var o=Math.max(this.indicatorWidth+3*s,8);this.indicatorStyle.width=o+"px",s=0}else if(s>this.maxPosX){this.transitionTime(500);var n=Math.max(this.indicatorWidth-3*(s-this.maxPosX),8);this.indicatorStyle.width=n+"px",s=this.maxPosX+this.indicatorWidth-n}else this.indicatorStyle.width=this.indicatorWidth+"px";this.x=s,this.scroller.options.useTransform?this.indicatorStyle[T.transform]="translateX("+s+"px)"+this.scroller.translateZ:this.indicatorStyle.left=s+"px"}},B.prototype.transitionTime=function(){var t=0this.maxPosX&&(t=this.maxPosX),i<0?i=0:i>this.maxPosY&&(i=this.maxPosY),t=Math.round(t/this.sizeRatioX),i=Math.round(i/this.sizeRatioY),this.scroller.scrollTo(t,i),this.scroller.trigger("scroll",{x:this.scroller.x,y:this.scroller.y})},B.prototype._shouldShow=function(){return"vertical"===this.direction&&this.scroller.hasVerticalScroll||"horizontal"===this.direction&&this.scroller.hasHorizontalScroll?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},B.prototype._calculate=function(){if("vertical"===this.direction){var t=this.wrapper.clientHeight;this.indicatorHeight=Math.max(Math.round(t*t/(this.scroller.scrollerHeight||t||1)),8),this.indicatorStyle.height=this.indicatorHeight+"px",this.maxPosY=t-this.indicatorHeight,this.sizeRatioY=this.maxPosY/this.scroller.maxScrollY}else{var i=this.wrapper.clientWidth;this.indicatorWidth=Math.max(Math.round(i*i/(this.scroller.scrollerWidth||i||1)),8),this.indicatorStyle.width=this.indicatorWidth+"px",this.maxPosX=i-this.indicatorWidth,this.sizeRatioX=this.maxPosX/this.scroller.maxScrollX}},B.prototype._addDOMEvents=function(){var t=h;this._handleDOMEvents(t)},B.prototype._removeDOMEvents=function(){var t=u;this._handleDOMEvents(t),this._handleMoveEvents(t)},B.prototype._handleMoveEvents=function(t){this.scroller.options.disableTouch||t(window,"touchmove",this),this.scroller.options.disableMouse||t(window,"mousemove",this)},B.prototype._handleDOMEvents=function(t){this.scroller.options.disableTouch||(t(this.indicator,"touchstart",this),t(window,"touchend",this)),this.scroller.options.disableMouse||(t(this.indicator,"mousedown",this),t(window,"mouseup",this))};var q,V,Z,j,G,$,J,K,Q,tt,it=2e3;function et(t){if(t&&t.classList)return t.classList.contains("tombstone")}function st(t,i){var e=this;this.options=i,U("function"==typeof this.options.createTombstone,"Infinite scroll need createTombstone Function to create tombstone"),U("function"==typeof this.options.fetch,"Infinite scroll need fetch Function to fetch new data."),U("function"==typeof this.options.render,"Infinite scroll need render Function to render each item."),this.firstAttachedItem=0,this.lastAttachedItem=0,this.anchorScrollTop=0,this.anchorItem={index:0,offset:0},this.tombstoneHeight=0,this.tombstoneWidth=0,this.tombstones=[],this.items=[],this.loadedItems=0,this.requestInProgress=!1,this.hasMore=!0,this.scroller=t,this.wrapperEl=this.scroller.wrapper,this.scrollerEl=this.scroller.scroller,this.scroller.on("scroll",function(){e.onScroll()}),this.scroller.on("resize",function(){e.onResize()}),this.onResize()}function ot(t,i){this.wrapper="string"==typeof t?document.querySelector(t):t,this.wrapper||F("Can not resolve the wrapper DOM."),this.scroller=this.wrapper.children[0],this.scroller||F("The wrapper need at least one child element to be scroller."),this.scrollerStyle=this.scroller.style,this._init(t,i)}return st.prototype.onScroll=function(){var t=-this.scroller.y,i=t-this.anchorScrollTop;this.anchorItem=0===t?{index:0,offset:0}:this._calculateAnchoredItem(this.anchorItem,i),this.anchorScrollTop=t;var e=this._calculateAnchoredItem(this.anchorItem,this.wrapperEl.offsetHeight),s=this.anchorItem.index,o=e.index;i<0?(s-=30,o+=10):(s-=10,o+=30),this.fill(s,o),this.maybeRequestContent()},st.prototype.onResize=function(){var t=this.options.createTombstone();t.style.position="absolute",this.scrollerEl.appendChild(t),t.style.display="",this.tombstoneHeight=t.offsetHeight,this.tombstoneWidth=t.offsetWidth,this.scrollerEl.removeChild(t);for(var i=0;ithis.firstAttachedItem;)i-=this.items[e-1].height||this.tombstoneHeight,e--;return i},st.prototype._setupAnimations=function(e,t){var s=this;for(var i in e){var o=e[i];this.items[i].node.style.transform="translateY("+(this.anchorScrollTop+o[1])+"px) scale("+this.tombstoneWidth/this.items[i].width+", "+this.tombstoneHeight/this.items[i].height+")",this.items[i].node.offsetTop,o[0].offsetTop,this.items[i].node.style.transition="transform 200ms"}for(var n=this.firstAttachedItem;n=this.items.length||!this.items[e].height)&&(s=Math.floor(Math.max(i,0)/this.tombstoneHeight))}return{index:e+=s,offset:i-=s*this.tombstoneHeight}},(q=ot).prototype._init=function(t,i){this._handleOptions(i),this._events={},this.x=0,this.y=0,this.directionX=0,this.directionY=0,this.setScale(1),this._addDOMEvents(),this._initExtFeatures(),this._watchTransition(),this.options.observeDOM&&this._initDOMObserver(),this.options.autoBlur&&this._handleAutoBlur(),this.refresh(),this.options.snap||this.scrollTo(this.options.startX,this.options.startY),this.enable()},q.prototype.setScale=function(t){this.lastScale=p(this.scale)?t:this.scale,this.scale=t},q.prototype._handleOptions=function(t){this.options=a({},E,t),this.translateZ=this.options.HWCompositing&&v?" translateZ(0)":"",this.options.useTransition=this.options.useTransition&&S,this.options.useTransform=this.options.useTransform&&x,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollX="horizontal"!==this.options.eventPassthrough&&this.options.scrollX,this.options.scrollY="vertical"!==this.options.eventPassthrough&&this.options.scrollY,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,!0===this.options.tap&&(this.options.tap="tap")},q.prototype._addDOMEvents=function(){var t=h;this._handleDOMEvents(t)},q.prototype._removeDOMEvents=function(){var t=u;this._handleDOMEvents(t)},q.prototype._handleDOMEvents=function(t){var i=this.options.bindToWrapper?this.wrapper:window;t(window,"orientationchange",this),t(window,"resize",this),this.options.click&&t(this.wrapper,"click",this,!0),this.options.disableMouse||(t(this.wrapper,"mousedown",this),t(i,"mousemove",this),t(i,"mousecancel",this),t(i,"mouseup",this)),y&&!this.options.disableTouch&&(t(this.wrapper,"touchstart",this),t(i,"touchmove",this),t(i,"touchcancel",this),t(i,"touchend",this)),t(this.scroller,T.transitionEnd,this)},q.prototype._initExtFeatures=function(){this.options.snap&&this._initSnap(),this.options.scrollbar&&this._initScrollbar(),this.options.pullUpLoad&&this._initPullUp(),this.options.pullDownRefresh&&this._initPullDown(),this.options.wheel&&this._initWheel(),this.options.mouseWheel&&this._initMouseWheel(),this.options.zoom&&this._initZoom(),this.options.infinity&&this._initInfinite()},q.prototype._watchTransition=function(){if("function"==typeof Object.defineProperty){var o=this,n=!1,t=this.useTransition?"isInTransition":"isAnimating";Object.defineProperty(this,t,{get:function(){return n},set:function(t){n=t;for(var i=o.scroller.children.length?o.scroller.children:[o.scroller],e=n&&!o.pulling?"none":"auto",s=0;sthis.minScrollX||this.xthis.minScrollY||this.ythis.options.momentumLimitTime&&nn+this.options.directionLockThreshold?this.directionLocked="h":n>=o+this.options.directionLockThreshold?this.directionLocked="v":this.directionLocked="n"),"h"===this.directionLocked){if("vertical"===this.options.eventPassthrough)t.preventDefault();else if("horizontal"===this.options.eventPassthrough)return void(this.initiated=!1);s=0}else if("v"===this.directionLocked){if("horizontal"===this.options.eventPassthrough)t.preventDefault();else if("vertical"===this.options.eventPassthrough)return void(this.initiated=!1);e=0}e=this.hasHorizontalScroll?e:0,s=this.hasVerticalScroll?s:0,this.movingDirectionX=0this.minScrollX||hthis.minScrollX&&p||hthis.minScrollX?this.minScrollX:this.maxScrollX),(a>this.minScrollY||athis.minScrollY&&l||athis.minScrollY?this.minScrollY:this.maxScrollY),this.moved||(this.moved=!0,this.trigger("scrollStart")),this._translate(h,a),r-this.startTime>this.options.momentumLimitTime&&(this.startTime=r,this.startX=this.x,this.startY=this.y,this.options.probeType===L&&this.trigger("scroll",{x:this.x,y:this.y})),this.options.probeType>L&&this.trigger("scroll",{x:this.x,y:this.y});var m=document.documentElement.scrollLeft||window.pageXOffset||document.body.scrollLeft,f=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop,g=this.pointX-m,v=this.pointY-f;(g>document.documentElement.clientWidth-this.options.momentumLimitDistance||gdocument.documentElement.clientHeight-this.options.momentumLimitDistance)&&this._end(t)}}},V.prototype._end=function(t){if(this.enabled&&!this.destroyed&&_[t.type]===this.initiated){this.initiated=!1,this.options.preventDefault&&!X(t.target,this.options.preventDefaultException)&&t.preventDefault(),this.options.stopPropagation&&t.stopPropagation(),this.trigger("touchEnd",{x:this.x,y:this.y}),this.isInTransition=!1;var i=Math.round(this.x),e=Math.round(this.y),s=i-this.absStartX,o=e-this.absStartY;if(this.directionX=0this.options.momentumLimitDistance||r>this.options.momentumLimitDistance)){var l=!1,c=!1,p=!1,d=!1,u=this.options.bounce;!1!==u&&(l=void 0===u.top||u.top,c=void 0===u.bottom||u.bottom,p=void 0===u.left||u.left,d=void 0===u.right||u.right);var m=this.directionX===C&&p||this.directionX===O&&d?this.wrapperWidth:0,f=this.directionY===A&&l||this.directionY===W&&c?this.wrapperHeight:0,g=this.hasHorizontalScroll?I(this.x,this.startX,n,this.maxScrollX,this.minScrollX,m,this.options):{destination:i,duration:0},v=this.hasVerticalScroll?I(this.y,this.startY,n,this.maxScrollY,this.minScrollY,f,this.options):{destination:e,duration:0};i=g.destination,e=v.destination,a=Math.max(g.duration,v.duration),this.isInTransition=!0}else this.options.wheel&&(e=Math.round(e/this.itemHeight)*this.itemHeight,a=this.options.wheel.adjustTime||400);var y=D.swipe;if(this.options.snap){var x=this._nearestSnap(i,e);this.currentPage=x,a=this.options.snapSpeed||Math.max(Math.max(Math.min(Math.abs(i-x.x),1e3),Math.min(Math.abs(e-x.y),1e3)),300),i=x.x,e=x.y,this.directionX=0,this.directionY=0,y=this.options.snap.easing||D.bounce}if(i!==this.x||e!==this.y)return(i>this.minScrollX||ithis.minScrollY||ethis.minScrollY?this.selectedIndex=0:ithis.minScrollX?this.minScrollX:n.leftthis.minScrollY?this.minScrollY:n.topthis.minScrollX?e=this.minScrollX:sthis.minScrollY?o=this.minScrollY:nm.maxScrollX&&a++;else for(o=Math.round(t/2),n=Math.round(i/2);e>-m.scrollerWidth;){for(m.pages[r]=[],s=h=0;s>-m.scrollerHeight;)m.pages[r][h]={x:Math.max(e,m.maxScrollX),y:Math.max(s,m.maxScrollY),width:t,height:i,cx:e-o,cy:s-n},s-=i,h++;e-=t,r++}m._checkSnapLoop();var p=f._loopX?1:0,d=f._loopY?1:0;m._goToPage(m.currentPage.pageX||p,m.currentPage.pageY||d,0);var u=f.threshold;u%1==0?(m.snapThresholdX=u,m.snapThresholdY=u):(m.snapThresholdX=Math.round(m.pages[m.currentPage.pageX][m.currentPage.pageY].width*u),m.snapThresholdY=Math.round(m.pages[m.currentPage.pageX][m.currentPage.pageY].height*u))}}),this.on("scrollEnd",function(){f.loop&&(f._loopX?(0===m.currentPage.pageX&&m._goToPage(m.pages.length-2,m.currentPage.pageY,0),m.currentPage.pageX===m.pages.length-1&&m._goToPage(1,m.currentPage.pageY,0)):(0===m.currentPage.pageY&&m._goToPage(m.currentPage.pageX,m.pages[0].length-2,0),m.currentPage.pageY===m.pages[0].length-1&&m._goToPage(m.currentPage.pageX,1,0)))}),!1!==f.listenFlick&&this.on("flick",function(){var t=f.speed||Math.max(Math.max(Math.min(Math.abs(m.x-m.startX),1e3),Math.min(Math.abs(m.y-m.startY),1e3)),300);m._goToPage(m.currentPage.pageX+m.directionX,m.currentPage.pageY+m.directionY,t)}),this.on("destroy",function(){if(f.loop){var t=m.scroller.children;2this.minScrollX?t=this.minScrollX:tthis.minScrollY?i=this.minScrollY:i=this.pages[e][0].cx){t=this.pages[e][0].x;break}s=this.pages[e].length;for(var o=0;o=this.pages[0][o].cy){i=this.pages[0][o].y;break}return e===this.currentPage.pageX&&((e+=this.directionX)<0?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),o===this.currentPage.pageY&&((o+=this.directionY)<0?o=0:o>=this.pages[0].length&&(o=this.pages[0].length-1),i=this.pages[0][o].y),{x:t,y:i,pageX:e,pageY:o}},j.prototype._goToPage=function(t){var i=1=this.pages.length?t=this.pages.length-1:t<0&&(t=0),this.pages[t])){i>=this.pages[t].length?i=this.pages[t].length-1:i<0&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?o.speed||Math.max(Math.max(Math.min(Math.abs(n-this.x),1e3),Math.min(Math.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,s)}},j.prototype.goToPage=function(t,i,e,s){var o=this.options.snap;if(o&&this.pages&&this.pages.length){if(o.loop){var n=void 0;o._loopX?((n=this.pages.length-2)<=t?t=n-1:t<0&&(t=0),t+=1):((n=this.pages[0].length-2)<=i?i=n-1:i<0&&(i=0),i+=1)}this._goToPage(t,i,e,s)}},j.prototype.next=function(t,i){if(this.options.snap){var e=this.currentPage.pageX,s=this.currentPage.pageY;++e>=this.pages.length&&this.hasVerticalScroll&&(e=0,s++),this._goToPage(e,s,t,i)}},j.prototype.prev=function(t,i){if(this.options.snap){var e=this.currentPage.pageX,s=this.currentPage.pageY;--e<0&&this.hasVerticalScroll&&(e=0,s--),this._goToPage(e,s,t,i)}},j.prototype.getCurrentPage=function(){var t=this.options.snap;return t?t.loop?t._loopX?a({},this.currentPage,{pageX:this.currentPage.pageX-1}):a({},this.currentPage,{pageY:this.currentPage.pageY-1}):this.currentPage:null},(G=ot).prototype.wheelTo=function(){var t=0this.minScrollX?d=this.minScrollX:dthis.minScrollY?u=this.minScrollY:uthis.minScrollX?n=this.minScrollX:nthis.minScrollY?r=this.minScrollY:rn?n:this.scalethis.maxPosY){this.transitionTime(500);var e=Math.max(this.indicatorHeight-3*(t-this.maxPosY),8);this.indicatorStyle.height=e+"px",t=this.maxPosY+this.indicatorHeight-e}else this.indicatorStyle.height=this.indicatorHeight+"px";this.y=t,this.scroller.options.useTransform?this.indicatorStyle[b.transform]="translateY("+t+"px)"+this.scroller.translateZ:this.indicatorStyle.top=t+"px"}else{var s=Math.round(this.sizeRatioX*this.scroller.x);if(s<0){this.transitionTime(500);var o=Math.max(this.indicatorWidth+3*s,8);this.indicatorStyle.width=o+"px",s=0}else if(s>this.maxPosX){this.transitionTime(500);var n=Math.max(this.indicatorWidth-3*(s-this.maxPosX),8);this.indicatorStyle.width=n+"px",s=this.maxPosX+this.indicatorWidth-n}else this.indicatorStyle.width=this.indicatorWidth+"px";this.x=s,this.scroller.options.useTransform?this.indicatorStyle[b.transform]="translateX("+s+"px)"+this.scroller.translateZ:this.indicatorStyle.left=s+"px"}},L.prototype.transitionTime=function(){var t=0this.maxPosX&&(t=this.maxPosX),i<0?i=0:i>this.maxPosY&&(i=this.maxPosY),t=Math.round(t/this.sizeRatioX),i=Math.round(i/this.sizeRatioY),this.scroller.scrollTo(t,i),this.scroller.trigger("scroll",{x:this.scroller.x,y:this.scroller.y})},L.prototype._shouldShow=function(){return"vertical"===this.direction&&this.scroller.hasVerticalScroll||"horizontal"===this.direction&&this.scroller.hasHorizontalScroll?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},L.prototype._calculate=function(){if("vertical"===this.direction){var t=this.wrapper.clientHeight;this.indicatorHeight=Math.max(Math.round(t*t/(this.scroller.scrollerHeight||t||1)),8),this.indicatorStyle.height=this.indicatorHeight+"px",this.maxPosY=t-this.indicatorHeight,this.sizeRatioY=this.maxPosY/this.scroller.maxScrollY}else{var i=this.wrapper.clientWidth;this.indicatorWidth=Math.max(Math.round(i*i/(this.scroller.scrollerWidth||i||1)),8),this.indicatorStyle.width=this.indicatorWidth+"px",this.maxPosX=i-this.indicatorWidth,this.sizeRatioX=this.maxPosX/this.scroller.maxScrollX}},L.prototype._addDOMEvents=function(){var t=h;this._handleDOMEvents(t)},L.prototype._removeDOMEvents=function(){var t=p;this._handleDOMEvents(t),this._handleMoveEvents(t)},L.prototype._handleMoveEvents=function(t){this.scroller.options.disableTouch||t(window,"touchmove",this),this.scroller.options.disableMouse||t(window,"mousemove",this)},L.prototype._handleDOMEvents=function(t){this.scroller.options.disableTouch||(t(this.indicator,"touchstart",this),t(window,"touchend",this)),this.scroller.options.disableMouse||(t(this.indicator,"mousedown",this),t(window,"mouseup",this))};var O,R,F,U,N,B,q,V,Z,j;function G(t){if(t&&t.classList)return t.classList.contains("tombstone")}function $(t,i){var e=this;this.options=i,A("function"==typeof this.options.createTombstone,"Infinite scroll need createTombstone Function to create tombstone"),A("function"==typeof this.options.fetch,"Infinite scroll need fetch Function to fetch new data."),A("function"==typeof this.options.render,"Infinite scroll need render Function to render each item."),this.firstAttachedItem=0,this.lastAttachedItem=0,this.anchorScrollTop=0,this.anchorItem={index:0,offset:0},this.tombstoneHeight=0,this.tombstoneWidth=0,this.tombstones=[],this.items=[],this.loadedItems=0,this.requestInProgress=!1,this.hasMore=!0,this.scroller=t,this.wrapperEl=this.scroller.wrapper,this.scrollerEl=this.scroller.scroller,this.scroller.on("scroll",function(){e.onScroll()}),this.scroller.on("resize",function(){e.onResize()}),this.scroller.on("destroy",function(){e.destroy()}),setTimeout(function(){e.onResize()})}function J(t,i){this.wrapper="string"==typeof t?document.querySelector(t):t,this.wrapper||z("Can not resolve the wrapper DOM."),this.scroller=this.wrapper.children[0],this.scroller||z("The wrapper need at least one child element to be scroller."),this.scrollerStyle=this.scroller.style,this._init(t,i)}return $.prototype.destroy=function(){var i=this;this.items.forEach(function(t){t.node&&(i.scrollerEl.removeChild(t.node),t.node=null)}),this.scroller.infiniteScroller=null,this.scroller=null,this.wrapperEl=null,this.scrollerEl=null,this.items=null,this.tombstones=null},$.prototype.onScroll=function(){var t=-this.scroller.y,i=t-this.anchorScrollTop;this.anchorItem=0===t?{index:0,offset:0}:this._calculateAnchoredItem(this.anchorItem,i),this.anchorScrollTop=t;var e=this._calculateAnchoredItem(this.anchorItem,this.scroller.wrapperHeight),s=this.anchorItem.index,o=e.index;i<0?(s-=30,o+=10):(s-=10,o+=30),this.fill(s,o),this.maybeRequestContent()},$.prototype.onResize=function(){var t=this.options.createTombstone();t.style.position="absolute",this.scrollerEl.appendChild(t),t.style.display="",this.tombstoneHeight=t.offsetHeight,this.tombstoneWidth=t.offsetWidth,this.scrollerEl.removeChild(t);for(var i=0;ithis.firstAttachedItem;)i-=this.items[e-1].height||this.tombstoneHeight,e--;return i},$.prototype._setupAnimations=function(e,t){var s=this;for(var i in e){var o=e[i];this.items[i].node.style[b.transform]="translateY("+(this.anchorScrollTop+o[1])+"px) scale("+this.tombstoneWidth/this.items[i].width+", "+this.tombstoneHeight/this.items[i].height+")",this.items[i].node.offsetTop,o[0].offsetTop,this.items[i].node.style[b.transition]=f+"transform 200ms"}for(var n=this.firstAttachedItem;n=this.items.length||!this.items[e].height)&&(s=Math.floor(Math.max(i,0)/this.tombstoneHeight))}return{index:e+=s,offset:i-=s*this.tombstoneHeight}},(O=J).prototype._init=function(t,i){this._handleOptions(i),this._events={},this.x=0,this.y=0,this.directionX=0,this.directionY=0,this.setScale(1),this._addDOMEvents(),this._initExtFeatures(),this._watchTransition(),this.options.observeDOM&&this._initDOMObserver(),this.options.autoBlur&&this._handleAutoBlur(),this.refresh(),this.options.snap||this.scrollTo(this.options.startX,this.options.startY),this.enable()},O.prototype.setScale=function(t){this.lastScale=c(this.scale)?t:this.scale,this.scale=t},O.prototype._handleOptions=function(t){this.options=a({},E,t),this.translateZ=this.options.HWCompositing&&y?" translateZ(0)":"",this.options.useTransition=this.options.useTransition&&T,this.options.useTransform=this.options.useTransform&&S,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollX="horizontal"!==this.options.eventPassthrough&&this.options.scrollX,this.options.scrollY="vertical"!==this.options.eventPassthrough&&this.options.scrollY,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,!0===this.options.tap&&(this.options.tap="tap")},O.prototype._addDOMEvents=function(){var t=h;this._handleDOMEvents(t)},O.prototype._removeDOMEvents=function(){var t=p;this._handleDOMEvents(t)},O.prototype._handleDOMEvents=function(t){var i=this.options.bindToWrapper?this.wrapper:window;t(window,"orientationchange",this),t(window,"resize",this),this.options.click&&t(this.wrapper,"click",this,!0),this.options.disableMouse||(t(this.wrapper,"mousedown",this),t(i,"mousemove",this),t(i,"mousecancel",this),t(i,"mouseup",this)),x&&!this.options.disableTouch&&(t(this.wrapper,"touchstart",this),t(i,"touchmove",this),t(i,"touchcancel",this),t(i,"touchend",this)),t(this.scroller,b.transitionEnd,this)},O.prototype._initExtFeatures=function(){this.options.snap&&this._initSnap(),this.options.scrollbar&&this._initScrollbar(),this.options.pullUpLoad&&this._initPullUp(),this.options.pullDownRefresh&&this._initPullDown(),this.options.wheel&&this._initWheel(),this.options.mouseWheel&&this._initMouseWheel(),this.options.zoom&&this._initZoom(),this.options.infinity&&this._initInfinite()},O.prototype._watchTransition=function(){if("function"==typeof Object.defineProperty){var o=this,n=!1,t=this.useTransition?"isInTransition":"isAnimating";Object.defineProperty(this,t,{get:function(){return n},set:function(t){n=t;for(var i=o.scroller.children.length?o.scroller.children:[o.scroller],e=n&&!o.pulling?"none":"auto",s=0;sthis.minScrollX||this.xthis.minScrollY||this.ythis.options.momentumLimitTime&&nn+this.options.directionLockThreshold?this.directionLocked="h":n>=o+this.options.directionLockThreshold?this.directionLocked="v":this.directionLocked="n"),"h"===this.directionLocked){if("vertical"===this.options.eventPassthrough)t.preventDefault();else if("horizontal"===this.options.eventPassthrough)return void(this.initiated=!1);s=0}else if("v"===this.directionLocked){if("horizontal"===this.options.eventPassthrough)t.preventDefault();else if("vertical"===this.options.eventPassthrough)return void(this.initiated=!1);e=0}e=this.hasHorizontalScroll?e:0,s=this.hasVerticalScroll?s:0,this.movingDirectionX=0this.minScrollX||hthis.minScrollX&&p||hthis.minScrollX?this.minScrollX:this.maxScrollX),(a>this.minScrollY||athis.minScrollY&&l||athis.minScrollY?this.minScrollY:this.maxScrollY),this.moved||(this.moved=!0,this.trigger("scrollStart")),this._translate(h,a),r-this.startTime>this.options.momentumLimitTime&&(this.startTime=r,this.startX=this.x,this.startY=this.y,1===this.options.probeType&&this.trigger("scroll",{x:this.x,y:this.y})),1document.documentElement.clientWidth-this.options.momentumLimitDistance||gdocument.documentElement.clientHeight-this.options.momentumLimitDistance)&&this._end(t)}}},R.prototype._end=function(t){if(this.enabled&&!this.destroyed&&_[t.type]===this.initiated){this.initiated=!1,this.options.preventDefault&&!X(t.target,this.options.preventDefaultException)&&t.preventDefault(),this.options.stopPropagation&&t.stopPropagation(),this.trigger("touchEnd",{x:this.x,y:this.y}),this.isInTransition=!1;var i=Math.round(this.x),e=Math.round(this.y),s=i-this.absStartX,o=e-this.absStartY;if(this.directionX=0this.options.momentumLimitDistance||r>this.options.momentumLimitDistance)){var l=!1,c=!1,p=!1,d=!1,u=this.options.bounce;!1!==u&&(l=void 0===u.top||u.top,c=void 0===u.bottom||u.bottom,p=void 0===u.left||u.left,d=void 0===u.right||u.right);var m=-1===this.directionX&&p||1===this.directionX&&d?this.wrapperWidth:0,f=-1===this.directionY&&l||1===this.directionY&&c?this.wrapperHeight:0,g=this.hasHorizontalScroll?I(this.x,this.startX,n,this.maxScrollX,this.minScrollX,m,this.options):{destination:i,duration:0},v=this.hasVerticalScroll?I(this.y,this.startY,n,this.maxScrollY,this.minScrollY,f,this.options):{destination:e,duration:0};i=g.destination,e=v.destination,a=Math.max(g.duration,v.duration),this.isInTransition=!0}else this.options.wheel&&(e=Math.round(e/this.itemHeight)*this.itemHeight,a=this.options.wheel.adjustTime||400);var y=D.swipe;if(this.options.snap){var x=this._nearestSnap(i,e);this.currentPage=x,a=this.options.snapSpeed||Math.max(Math.max(Math.min(Math.abs(i-x.x),1e3),Math.min(Math.abs(e-x.y),1e3)),300),i=x.x,e=x.y,this.directionX=0,this.directionY=0,y=this.options.snap.easing||D.bounce}if(i!==this.x||e!==this.y)return(i>this.minScrollX||ithis.minScrollY||ethis.minScrollY?this.selectedIndex=0:ithis.minScrollX?this.minScrollX:n.leftthis.minScrollY?this.minScrollY:n.topthis.minScrollX?e=this.minScrollX:sthis.minScrollY?o=this.minScrollY:nm.maxScrollX&&a++;else for(o=Math.round(t/2),n=Math.round(i/2);e>-m.scrollerWidth;){for(m.pages[r]=[],s=h=0;s>-m.scrollerHeight;)m.pages[r][h]={x:Math.max(e,m.maxScrollX),y:Math.max(s,m.maxScrollY),width:t,height:i,cx:e-o,cy:s-n},s-=i,h++;e-=t,r++}m._checkSnapLoop();var p=f._loopX?1:0,d=f._loopY?1:0;m._goToPage(m.currentPage.pageX||p,m.currentPage.pageY||d,0);var u=f.threshold;m.snapThresholdY=u%1==0?m.snapThresholdX=u:(m.snapThresholdX=Math.round(m.pages[m.currentPage.pageX][m.currentPage.pageY].width*u),Math.round(m.pages[m.currentPage.pageX][m.currentPage.pageY].height*u))}}),this.on("scrollEnd",function(){f.loop&&(f._loopX?(0===m.currentPage.pageX&&m._goToPage(m.pages.length-2,m.currentPage.pageY,0),m.currentPage.pageX===m.pages.length-1&&m._goToPage(1,m.currentPage.pageY,0)):(0===m.currentPage.pageY&&m._goToPage(m.currentPage.pageX,m.pages[0].length-2,0),m.currentPage.pageY===m.pages[0].length-1&&m._goToPage(m.currentPage.pageX,1,0)))}),!1!==f.listenFlick&&this.on("flick",function(){var t=f.speed||Math.max(Math.max(Math.min(Math.abs(m.x-m.startX),1e3),Math.min(Math.abs(m.y-m.startY),1e3)),300);m._goToPage(m.currentPage.pageX+m.directionX,m.currentPage.pageY+m.directionY,t)}),this.on("destroy",function(){if(f.loop){var t=m.scroller.children;2this.minScrollX?t=this.minScrollX:tthis.minScrollY?i=this.minScrollY:i=this.pages[e][0].cx){t=this.pages[e][0].x;break}s=this.pages[e].length;for(var o=0;o=this.pages[0][o].cy){i=this.pages[0][o].y;break}return e===this.currentPage.pageX&&((e+=this.directionX)<0?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),o===this.currentPage.pageY&&((o+=this.directionY)<0?o=0:o>=this.pages[0].length&&(o=this.pages[0].length-1),i=this.pages[0][o].y),{x:t,y:i,pageX:e,pageY:o}},U.prototype._goToPage=function(t){var i=1=this.pages.length?t=this.pages.length-1:t<0&&(t=0),this.pages[t])){i>=this.pages[t].length?i=this.pages[t].length-1:i<0&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?o.speed||Math.max(Math.max(Math.min(Math.abs(n-this.x),1e3),Math.min(Math.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,s)}},U.prototype.goToPage=function(t,i,e,s){var o=this.options.snap;if(o&&this.pages&&this.pages.length){if(o.loop){var n=void 0;o._loopX?((n=this.pages.length-2)<=t?t=n-1:t<0&&(t=0),t+=1):((n=this.pages[0].length-2)<=i?i=n-1:i<0&&(i=0),i+=1)}this._goToPage(t,i,e,s)}},U.prototype.next=function(t,i){if(this.options.snap){var e=this.currentPage.pageX,s=this.currentPage.pageY;++e>=this.pages.length&&this.hasVerticalScroll&&(e=0,s++),this._goToPage(e,s,t,i)}},U.prototype.prev=function(t,i){if(this.options.snap){var e=this.currentPage.pageX,s=this.currentPage.pageY;--e<0&&this.hasVerticalScroll&&(e=0,s--),this._goToPage(e,s,t,i)}},U.prototype.getCurrentPage=function(){var t=this.options.snap;return t?t.loop?t._loopX?a({},this.currentPage,{pageX:this.currentPage.pageX-1}):a({},this.currentPage,{pageY:this.currentPage.pageY-1}):this.currentPage:null},(N=J).prototype.wheelTo=function(){var t=0this.minScrollX?d=this.minScrollX:dthis.minScrollY?u=this.minScrollY:uthis.minScrollX?n=this.minScrollX:nthis.minScrollY?r=this.minScrollY:rn?n:this.scale