pure-scroll
Version:
一个简洁且好用的滚动库, 基于better-scroll封装
25 lines (23 loc) • 61.2 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).pureScroll=e()}(this,(function(){"use strict";
/*!
* better-scroll / core
* (c) 2016-2021 ustbhuangyi
* Released under the MIT License.
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var t=function(e,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])},t(e,o)};function e(e,o){function n(){this.constructor=e}t(e,o),e.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}var o=function(){return o=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},o.apply(this,arguments)};function n(){for(var t=0,e=0,o=arguments.length;e<o;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<o;e++)for(var i=arguments[e],s=0,l=i.length;s<l;s++,r++)n[r]=i[s];return n}var r=[{sourceKey:"scroller.scrollBehaviorX.currentPos",key:"x"},{sourceKey:"scroller.scrollBehaviorY.currentPos",key:"y"},{sourceKey:"scroller.scrollBehaviorX.hasScroll",key:"hasHorizontalScroll"},{sourceKey:"scroller.scrollBehaviorY.hasScroll",key:"hasVerticalScroll"},{sourceKey:"scroller.scrollBehaviorX.contentSize",key:"scrollerWidth"},{sourceKey:"scroller.scrollBehaviorY.contentSize",key:"scrollerHeight"},{sourceKey:"scroller.scrollBehaviorX.maxScrollPos",key:"maxScrollX"},{sourceKey:"scroller.scrollBehaviorY.maxScrollPos",key:"maxScrollY"},{sourceKey:"scroller.scrollBehaviorX.minScrollPos",key:"minScrollX"},{sourceKey:"scroller.scrollBehaviorY.minScrollPos",key:"minScrollY"},{sourceKey:"scroller.scrollBehaviorX.movingDirection",key:"movingDirectionX"},{sourceKey:"scroller.scrollBehaviorY.movingDirection",key:"movingDirectionY"},{sourceKey:"scroller.scrollBehaviorX.direction",key:"directionX"},{sourceKey:"scroller.scrollBehaviorY.direction",key:"directionY"},{sourceKey:"scroller.actions.enabled",key:"enabled"},{sourceKey:"scroller.animater.pending",key:"pending"},{sourceKey:"scroller.animater.stop",key:"stop"},{sourceKey:"scroller.scrollTo",key:"scrollTo"},{sourceKey:"scroller.scrollBy",key:"scrollBy"},{sourceKey:"scroller.scrollToElement",key:"scrollToElement"},{sourceKey:"scroller.resetPosition",key:"resetPosition"}];function i(t){console.error("[BScroll warn]: "+t)}var s="undefined"!=typeof window,l=s&&navigator.userAgent.toLowerCase(),h=!(!l||!/wechatdevtools/.test(l)),a=l&&l.indexOf("android")>0,c=function(){if("string"==typeof l){var t=/os (\d\d?_\d(_\d)?)/.exec(l);if(!t)return!1;var e=t[1].split("_").map((function(t){return parseInt(t,10)}));return!!(13===e[0]&&e[1]>=4)}return!1}(),p=!1;if(s){try{var u={};Object.defineProperty(u,"passive",{get:function(){p=!0}}),window.addEventListener("test-passive",(function(){}),u)}catch(t){}}function d(){return window.performance&&window.performance.now&&window.performance.timing?window.performance.now()+window.performance.timing.navigationStart:+new Date}var f=function(t,e){for(var o in e)t[o]=e[o];return t};function v(t){return null==t}function y(t,e,o){return t<e?e:t>o?o:t}var m=s&&document.createElement("div").style,g=function(){if(!s)return!1;for(var t=0,e=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];t<e.length;t++){var o=e[t];if(void 0!==m[o.value])return o.key}return!1}();function k(t){return!1===g?t:"standard"===g?"transitionEnd"===t?"transitionend":t:g+t.charAt(0).toUpperCase()+t.substr(1)}function T(t){return"string"==typeof t?document.querySelector(t):t}function w(t,e,o,n){var r=p?{passive:!1,capture:!!n}:!!n;t.addEventListener(e,o,r)}function b(t,e,o,n){t.removeEventListener(e,o,{capture:!!n})}function S(t){for(var e=0,o=0;t;)e-=t.offsetLeft,o-=t.offsetTop,t=t.offsetParent;return{left:e,top:o}}g&&"standard"!==g&&g.toLowerCase();var P=k("transform"),E=k("transition"),C=s&&k("perspective")in m,B=s&&("ontouchstart"in window||h),D=s&&E in m,x={transform:P,transition:E,transitionTimingFunction:k("transitionTimingFunction"),transitionDuration:k("transitionDuration"),transitionDelay:k("transitionDelay"),transformOrigin:k("transformOrigin"),transitionEnd:k("transitionEnd"),transitionProperty:k("transitionProperty")},M={touchstart:1,touchmove:1,touchend:1,touchcancel:1,mousedown:2,mousemove:2,mouseup:2};function A(t){if(t instanceof window.SVGElement){var e=t.getBoundingClientRect();return{top:e.top,left:e.left,width:e.width,height:e.height}}return{top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth,height:t.offsetHeight}}function O(t,e){for(var o in e)if(e[o].test(t[o]))return!0;return!1}var X=O;function Y(t,e){var n;void 0===e&&(e="click"),"mouseup"===t.type?n=t:"touchend"!==t.type&&"touchcancel"!==t.type||(n=t.changedTouches[0]);var r,i={};n&&(i.screenX=n.screenX||0,i.screenY=n.screenY||0,i.clientX=n.clientX||0,i.clientY=n.clientY||0);var s={ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey};if("undefined"!=typeof MouseEvent)try{r=new MouseEvent(e,f(o({bubbles:true,cancelable:true},s),i))}catch(t){l()}else l();function l(){(r=document.createEvent("Event")).initEvent(e,true,true),f(r,i)}r.forwardedTouchEvent=!0,r._constructed=!0,t.target.dispatchEvent(r)}var L={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(t){return 1+--t*t*t*t*t}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(t){return 1- --t*t*t*t}}},H=s&&window;function z(){}var F=s?H.requestAnimationFrame||H.webkitRequestAnimationFrame||H.mozRequestAnimationFrame||H.oRequestAnimationFrame||function(t){return window.setTimeout(t,t.interval||16.666666666666668)}:z,_=s?H.cancelAnimationFrame||H.webkitCancelAnimationFrame||H.mozCancelAnimationFrame||H.oCancelAnimationFrame||function(t){window.clearTimeout(t)}:z,W=function(t){},j={enumerable:!0,configurable:!0,get:W,set:W};var U=function(){function t(t){this.events={},this.eventTypes={},this.registerType(t)}return t.prototype.on=function(t,e,o){return void 0===o&&(o=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,o]),this},t.prototype.once=function(t,e,o){var n=this;void 0===o&&(o=this),this.hasType(t);var r=function(){for(var i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];n.off(t,r);var l=e.apply(o,i);if(!0===l)return l};return r.fn=e,this.on(t,r),this},t.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),!e)return this.events[t]=[],this;var o=this.events[t];if(!o)return this;for(var n=o.length;n--;)(o[n][0]===e||o[n][0]&&o[n][0].fn===e)&&o.splice(n,1);return this}},t.prototype.trigger=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.hasType(t);var r=this.events[t];if(r)for(var i,s=r.length,l=n(r),h=0;h<s;h++){var a=l[h],c=a[0],p=a[1];if(c&&!0===(i=c.apply(p,e)))return i}},t.prototype.registerType=function(t){var e=this;t.forEach((function(t){e.eventTypes[t]=t}))},t.prototype.destroy=function(){this.events={},this.eventTypes={}},t.prototype.hasType=function(t){var e=this.eventTypes;e[t]===t||i('EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(e).map((function(t){return JSON.stringify(t)}))+"]")},t}(),R=function(){function t(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}return t.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},t.prototype.addDOMEvents=function(){this.handleDOMEvents(w)},t.prototype.removeDOMEvents=function(){this.handleDOMEvents(b)},t.prototype.handleDOMEvents=function(t){var e=this,o=this.wrapper;this.events.forEach((function(n){t(o,n.name,e,!!n.capture)}))},t.prototype.handleEvent=function(t){var e=t.type;this.events.some((function(o){return o.name===e&&(o.handler(t),!0)}))},t}(),K=function(t){function o(){var e=t.call(this)||this;return e.startX=0,e.startY=0,e.scrollX=!1,e.scrollY=!0,e.freeScroll=!1,e.directionLockThreshold=0,e.eventPassthrough="",e.click=!1,e.dblclick=!1,e.tap="",e.bounce={top:!0,bottom:!0,left:!0,right:!0},e.bounceTime=800,e.momentum=!0,e.momentumLimitTime=300,e.momentumLimitDistance=15,e.swipeTime=2500,e.swipeBounceTime=500,e.deceleration=.0015,e.flickLimitTime=200,e.flickLimitDistance=100,e.resizePolling=60,e.probeType=0,e.stopPropagation=!1,e.preventDefault=!0,e.preventDefaultException={tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/},e.tagException={tagName:/^TEXTAREA$/},e.HWCompositing=!0,e.useTransition=!0,e.bindToWrapper=!1,e.bindToTarget=!1,e.disableMouse=B,e.disableTouch=!B,e.autoBlur=!0,e.autoEndDistance=5,e.outOfBoundaryDampingFactor=1/3,e.specifiedIndexAsContent=0,e.quadrant=1,e}return e(o,t),o.prototype.merge=function(t){if(!t)return this;for(var e in t)"bounce"!==e?this[e]=t[e]:this.bounce=this.resolveBounce(t[e]);return this},o.prototype.process=function(){return this.translateZ=this.HWCompositing&&C?" translateZ(1px)":"",this.useTransition=this.useTransition&&D,this.preventDefault=!this.eventPassthrough&&this.preventDefault,this.scrollX="horizontal"!==this.eventPassthrough&&this.scrollX,this.scrollY="vertical"!==this.eventPassthrough&&this.scrollY,this.freeScroll=this.freeScroll&&!this.eventPassthrough,this.scrollX=!!this.freeScroll||this.scrollX,this.scrollY=!!this.freeScroll||this.scrollY,this.directionLockThreshold=this.eventPassthrough?0:this.directionLockThreshold,this},o.prototype.resolveBounce=function(t){var e={top:!0,right:!0,bottom:!0,left:!0};return"object"==typeof t?f(e,t):t?e:{top:!1,right:!1,bottom:!1,left:!1}},o}((function(){})),I=function(){function t(t,e){this.wrapper=t,this.options=e,this.hooks=new U(["beforeStart","start","move","end","click"]),this.handleDOMEvents()}return t.prototype.handleDOMEvents=function(){var t=this.options,e=t.bindToWrapper,o=t.disableMouse,n=t.disableTouch,r=t.click,i=this.wrapper,s=e?i:window,l=[],h=[],a=!n,c=!o;r&&l.push({name:"click",handler:this.click.bind(this),capture:!0}),a&&(l.push({name:"touchstart",handler:this.start.bind(this)}),h.push({name:"touchmove",handler:this.move.bind(this)},{name:"touchend",handler:this.end.bind(this)},{name:"touchcancel",handler:this.end.bind(this)})),c&&(l.push({name:"mousedown",handler:this.start.bind(this)}),h.push({name:"mousemove",handler:this.move.bind(this)},{name:"mouseup",handler:this.end.bind(this)})),this.wrapperEventRegister=new R(i,l),this.targetEventRegister=new R(s,h)},t.prototype.beforeHandler=function(t,e){var o=this.options,n=o.preventDefault,r=o.stopPropagation,i=o.preventDefaultException;({start:function(){return n&&!O(t.target,i)},end:function(){return n&&!O(t.target,i)},move:function(){return n}})[e]()&&t.preventDefault(),r&&t.stopPropagation()},t.prototype.setInitiated=function(t){void 0===t&&(t=0),this.initiated=t},t.prototype.start=function(t){var e=M[t.type];if(!this.initiated||this.initiated===e)if(this.setInitiated(e),X(t.target,this.options.tagException))this.setInitiated();else if((2!==e||0===t.button)&&!this.hooks.trigger(this.hooks.eventTypes.beforeStart,t)){this.beforeHandler(t,"start");var o=t.touches?t.touches[0]:t;this.pointX=o.pageX,this.pointY=o.pageY,this.hooks.trigger(this.hooks.eventTypes.start,t)}},t.prototype.move=function(t){if(M[t.type]===this.initiated){this.beforeHandler(t,"move");var e=t.touches?t.touches[0]:t,o=e.pageX-this.pointX,n=e.pageY-this.pointY;if(this.pointX=e.pageX,this.pointY=e.pageY,!this.hooks.trigger(this.hooks.eventTypes.move,{deltaX:o,deltaY:n,e:t})){var r=document.documentElement.scrollLeft||window.pageXOffset||document.body.scrollLeft,i=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop,s=this.pointX-r,l=this.pointY-i,h=this.options.autoEndDistance;(s>document.documentElement.clientWidth-h||l>document.documentElement.clientHeight-h||s<h||l<h)&&this.end(t)}}},t.prototype.end=function(t){M[t.type]===this.initiated&&(this.setInitiated(),this.beforeHandler(t,"end"),this.hooks.trigger(this.hooks.eventTypes.end,t))},t.prototype.click=function(t){this.hooks.trigger(this.hooks.eventTypes.click,t)},t.prototype.setContent=function(t){t!==this.wrapper&&(this.wrapper=t,this.rebindDOMEvents())},t.prototype.rebindDOMEvents=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.handleDOMEvents()},t.prototype.destroy=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.hooks.destroy()},t}(),N={x:["translateX","px"],y:["translateY","px"]},$=function(){function t(t){this.setContent(t),this.hooks=new U(["beforeTranslate","translate"])}return t.prototype.getComputedPosition=function(){var t=window.getComputedStyle(this.content,null)[x.transform].split(")")[0].split(", ");return{x:+(t[12]||t[4])||0,y:+(t[13]||t[5])||0}},t.prototype.translate=function(t){var e=[];Object.keys(t).forEach((function(o){if(N[o]){var n=N[o][0];if(n){var r=N[o][1],i=t[o];e.push(n+"("+i+r+")")}}})),this.hooks.trigger(this.hooks.eventTypes.beforeTranslate,e,t),this.style[x.transform]=e.join(" "),this.hooks.trigger(this.hooks.eventTypes.translate,t)},t.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style)},t.prototype.destroy=function(){this.hooks.destroy()},t}(),q=function(){function t(t,e,o){this.translater=e,this.options=o,this.timer=0,this.hooks=new U(["move","end","beforeForceStop","forceStop","callStop","time","timeFunction"]),this.setContent(t)}return t.prototype.translate=function(t){this.translater.translate(t)},t.prototype.setPending=function(t){this.pending=t},t.prototype.setForceStopped=function(t){this.forceStopped=t},t.prototype.setCallStop=function(t){this.callStopWhenPending=t},t.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style,this.stop())},t.prototype.clearTimer=function(){this.timer&&(_(this.timer),this.timer=0)},t.prototype.destroy=function(){this.hooks.destroy(),_(this.timer)},t}(),V=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return e(o,t),o.prototype.startProbe=function(t,e){var o=this,n=t,r=function(){var i=o.translater.getComputedPosition();(function(t,e,o,n){var r=function(t,e){var o=t-e;return o>0?-1:o<0?1:0},i=r(e.x,t.x),s=r(e.y,t.y),l=o.x-n.x,h=o.y-n.y;return i*l<=0&&s*h<=0})(t,e,i,n)&&o.hooks.trigger(o.hooks.eventTypes.move,i),o.pending||(o.callStopWhenPending?o.callStopWhenPending=!1:o.hooks.trigger(o.hooks.eventTypes.end,i)),n=i,o.pending&&(o.timer=F(r))};this.callStopWhenPending&&this.setCallStop(!1),_(this.timer),r()},o.prototype.transitionTime=function(t){void 0===t&&(t=0),this.style[x.transitionDuration]=t+"ms",this.hooks.trigger(this.hooks.eventTypes.time,t)},o.prototype.transitionTimingFunction=function(t){this.style[x.transitionTimingFunction]=t,this.hooks.trigger(this.hooks.eventTypes.timeFunction,t)},o.prototype.transitionProperty=function(){this.style[x.transitionProperty]=x.transform},o.prototype.move=function(t,e,o,n){this.setPending(o>0),this.transitionTimingFunction(n),this.transitionProperty(),this.transitionTime(o),this.translate(e);var r=3===this.options.probeType;o&&r&&this.startProbe(t,e),o||(this._reflow=this.content.offsetHeight,r&&this.hooks.trigger(this.hooks.eventTypes.move,e),this.hooks.trigger(this.hooks.eventTypes.end,e))},o.prototype.doStop=function(){var t=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),t){this.setPending(!1),_(this.timer);var e=this.translater.getComputedPosition(),o=e.x,n=e.y;this.transitionTime(),this.translate({x:o,y:n}),this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,{x:o,y:n})}return t},o.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)},o}(q),Z=function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return e(o,t),o.prototype.move=function(t,e,o,n){if(!o)return this.translate(e),3===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.move,e),void this.hooks.trigger(this.hooks.eventTypes.end,e);this.animate(t,e,o,n)},o.prototype.animate=function(t,e,o,n){var r=this,i=d(),s=i+o,l=3===this.options.probeType,h=function(){var a=d();if(a>=s)return r.translate(e),l&&r.hooks.trigger(r.hooks.eventTypes.move,e),void r.hooks.trigger(r.hooks.eventTypes.end,e);var c=n(a=(a-i)/o),p={};Object.keys(e).forEach((function(o){var n=t[o],r=e[o];p[o]=(r-n)*c+n})),r.translate(p),l&&r.hooks.trigger(r.hooks.eventTypes.move,p),r.pending&&(r.timer=F(h)),r.pending||(r.callStopWhenPending?r.callStopWhenPending=!1:r.hooks.trigger(r.hooks.eventTypes.end,e))};this.setPending(!0),this.callStopWhenPending&&this.setCallStop(!1),_(this.timer),h()},o.prototype.doStop=function(){var t=this.pending;if(this.setForceStopped(!1),this.setCallStop(!1),t){this.setPending(!1),_(this.timer);var e=this.translater.getComputedPosition();this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,e)}return t},o.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)},o}(q);var J,G,Q,tt,et=function(){function t(t,e,o){this.wrapper=t,this.options=o,this.hooks=new U(["beforeComputeBoundary","computeBoundary","momentum","end","ignoreHasScroll"]),this.refresh(e)}return t.prototype.start=function(){this.dist=0,this.setMovingDirection(0),this.setDirection(0)},t.prototype.move=function(t){return t=this.hasScroll?t:0,this.setMovingDirection(t),this.performDampingAlgorithm(t,this.options.outOfBoundaryDampingFactor)},t.prototype.setMovingDirection=function(t){this.movingDirection=t>0?-1:t<0?1:0},t.prototype.setDirection=function(t){this.direction=t>0?-1:t<0?1:0},t.prototype.performDampingAlgorithm=function(t,e){var o=this.currentPos+t;return(o>this.minScrollPos||o<this.maxScrollPos)&&(o=o>this.minScrollPos&&this.options.bounces[0]||o<this.maxScrollPos&&this.options.bounces[1]?this.currentPos+t*e:o>this.minScrollPos?this.minScrollPos:this.maxScrollPos),o},t.prototype.end=function(t){var e={duration:0},o=Math.abs(this.currentPos-this.startPos);if(this.options.momentum&&t<this.options.momentumLimitTime&&o>this.options.momentumLimitDistance){var n=-1===this.direction&&this.options.bounces[0]||1===this.direction&&this.options.bounces[1]?this.wrapperSize:0;e=this.hasScroll?this.momentum(this.currentPos,this.startPos,t,this.maxScrollPos,this.minScrollPos,n,this.options):{destination:this.currentPos,duration:0}}else this.hooks.trigger(this.hooks.eventTypes.end,e);return e},t.prototype.momentum=function(t,e,o,n,r,i,s){void 0===s&&(s=this.options);var l=t-e,h=Math.abs(l)/o,a=s.deceleration,c=s.swipeBounceTime,p=s.swipeTime,u={destination:t+h*h/a*(l<0?-1:1),duration:Math.min(p,2*h/a),rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,u,l),u.destination<n?(u.destination=i?Math.max(n-i/4,n-i/u.rate*h):n,u.duration=c):u.destination>r&&(u.destination=i?Math.min(r+i/4,r+i/u.rate*h):r,u.duration=c),u.destination=Math.round(u.destination),u},t.prototype.updateDirection=function(){var t=this.currentPos-this.absStartPos;this.setDirection(t)},t.prototype.refresh=function(t){var e=this.options.rect,o=e.size,n=e.position,r="static"===window.getComputedStyle(this.wrapper,null).position,i=A(this.wrapper);this.wrapperSize=this.wrapper["width"===o?"clientWidth":"clientHeight"],this.setContent(t);var s=A(this.content);this.contentSize=s[o],this.relativeOffset=s[n],r&&(this.relativeOffset-=i[n]),this.computeBoundary(),this.setDirection(0)},t.prototype.setContent=function(t){t!==this.content&&(this.content=t,this.resetState())},t.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},t.prototype.computeBoundary=function(){this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);var t={minScrollPos:0,maxScrollPos:this.wrapperSize-this.contentSize};t.maxScrollPos<0&&(t.maxScrollPos-=this.relativeOffset,0===this.options.specifiedIndexAsContent&&(t.minScrollPos=-this.relativeOffset)),this.hooks.trigger(this.hooks.eventTypes.computeBoundary,t),this.minScrollPos=t.minScrollPos,this.maxScrollPos=t.maxScrollPos,this.hasScroll=this.options.scrollable&&this.maxScrollPos<this.minScrollPos,!this.hasScroll&&this.minScrollPos<this.maxScrollPos&&(this.maxScrollPos=this.minScrollPos,this.contentSize=this.wrapperSize)},t.prototype.updatePosition=function(t){this.currentPos=t},t.prototype.getCurrentPos=function(){return this.currentPos},t.prototype.checkInBoundary=function(){var t=this.adjustPosition(this.currentPos);return{position:t,inBoundary:t===this.getCurrentPos()}},t.prototype.adjustPosition=function(t){return this.hasScroll||this.hooks.trigger(this.hooks.eventTypes.ignoreHasScroll)?t>this.minScrollPos?t=this.minScrollPos:t<this.maxScrollPos&&(t=this.maxScrollPos):t=this.minScrollPos,t},t.prototype.updateStartPos=function(){this.startPos=this.currentPos},t.prototype.updateAbsStartPos=function(){this.absStartPos=this.currentPos},t.prototype.resetStartPos=function(){this.updateStartPos(),this.updateAbsStartPos()},t.prototype.getAbsDist=function(t){return this.dist+=t,Math.abs(this.dist)},t.prototype.destroy=function(){this.hooks.destroy()},t}(),ot=((J={}).yes=function(t){return!0},J.no=function(t){return t.preventDefault(),!1},J),nt=((G={}).horizontal=((Q={}).yes="horizontal",Q.no="vertical",Q),G.vertical=((tt={}).yes="vertical",tt.no="horizontal",tt),G),rt=function(){function t(t,e,o){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=o,this.reset()}return t.prototype.reset=function(){this.directionLocked=""},t.prototype.checkMovingDirection=function(t,e,o){return this.computeDirectionLock(t,e),this.handleEventPassthrough(o)},t.prototype.adjustDelta=function(t,e){return"horizontal"===this.directionLocked?e=0:"vertical"===this.directionLocked&&(t=0),{deltaX:t,deltaY:e}},t.prototype.computeDirectionLock=function(t,e){""!==this.directionLocked||this.freeScroll||(t>e+this.directionLockThreshold?this.directionLocked="horizontal":e>=t+this.directionLockThreshold?this.directionLocked="vertical":this.directionLocked="none")},t.prototype.handleEventPassthrough=function(t){var e=nt[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return ot.yes(t);if(this.eventPassthrough===e.no)return ot.no(t)}return!1},t}(),it=function(){function t(t,e,o,n,r){this.hooks=new U(["start","beforeMove","scrollStart","scroll","beforeEnd","end","scrollEnd","contentNotMoved","detectMovingDirection","coordinateTransformation"]),this.scrollBehaviorX=t,this.scrollBehaviorY=e,this.actionsHandler=o,this.animater=n,this.options=r,this.directionLockAction=new rt(r.directionLockThreshold,r.freeScroll,r.eventPassthrough),this.enabled=!0,this.bindActionsHandler()}return t.prototype.bindActionsHandler=function(){var t=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,(function(e){return!t.enabled||t.handleStart(e)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,(function(e){var o=e.deltaX,n=e.deltaY,r=e.e;if(!t.enabled)return!0;var i=function(t,e,o){return 2===o?[e,-t]:3===o?[-t,-e]:4===o?[-e,t]:[t,e]}(o,n,t.options.quadrant),s={deltaX:i[0],deltaY:i[1]};return t.hooks.trigger(t.hooks.eventTypes.coordinateTransformation,s),t.handleMove(s.deltaX,s.deltaY,r)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,(function(e){return!t.enabled||t.handleEnd(e)})),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,(function(e){t.enabled&&!e._constructed&&t.handleClick(e)}))},t.prototype.handleStart=function(t){var e=d();this.fingerMoved=!1,this.contentMoved=!1,this.startTime=e,this.directionLockAction.reset(),this.scrollBehaviorX.start(),this.scrollBehaviorY.start(),this.animater.doStop(),this.scrollBehaviorX.resetStartPos(),this.scrollBehaviorY.resetStartPos(),this.hooks.trigger(this.hooks.eventTypes.start,t)},t.prototype.handleMove=function(t,e,o){if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,o)){var n=this.scrollBehaviorX.getAbsDist(t),r=this.scrollBehaviorY.getAbsDist(e),i=d();if(this.checkMomentum(n,r,i))return!0;if(this.directionLockAction.checkMovingDirection(n,r,o))return this.actionsHandler.setInitiated(),!0;var s=this.directionLockAction.adjustDelta(t,e),l=this.scrollBehaviorX.getCurrentPos(),h=this.scrollBehaviorX.move(s.deltaX),a=this.scrollBehaviorY.getCurrentPos(),c=this.scrollBehaviorY.move(s.deltaY);if(!this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)){this.fingerMoved||(this.fingerMoved=!0);var p=h!==l||c!==a;this.contentMoved||p||this.hooks.trigger(this.hooks.eventTypes.contentNotMoved),!this.contentMoved&&p&&(this.contentMoved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.contentMoved&&p&&(this.animater.translate({x:h,y:c}),this.dispatchScroll(i))}}},t.prototype.dispatchScroll=function(t){t-this.startTime>this.options.momentumLimitTime&&(this.startTime=t,this.scrollBehaviorX.updateStartPos(),this.scrollBehaviorY.updateStartPos(),1===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())),this.options.probeType>1&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())},t.prototype.checkMomentum=function(t,e,o){return o-this.endTime>this.options.momentumLimitTime&&e<this.options.momentumLimitDistance&&t<this.options.momentumLimitDistance},t.prototype.handleEnd=function(t){if(!this.hooks.trigger(this.hooks.eventTypes.beforeEnd,t)){var e=this.getCurrentPos();if(this.scrollBehaviorX.updateDirection(),this.scrollBehaviorY.updateDirection(),this.hooks.trigger(this.hooks.eventTypes.end,t,e))return!0;e=this.ensureIntegerPos(e),this.animater.translate(e),this.endTime=d();var o=this.endTime-this.startTime;this.hooks.trigger(this.hooks.eventTypes.scrollEnd,e,o)}},t.prototype.ensureIntegerPos=function(t){this.ensuringInteger=!0;var e=t.x,o=t.y,n=this.scrollBehaviorX,r=n.minScrollPos,i=n.maxScrollPos,s=this.scrollBehaviorY,l=s.minScrollPos,h=s.maxScrollPos;return e=e>0?Math.ceil(e):Math.floor(e),o=o>0?Math.ceil(o):Math.floor(o),{x:e=y(e,i,r),y:o=y(o,h,l)}},t.prototype.handleClick=function(t){O(t.target,this.options.preventDefaultException)||(t.preventDefault(),t.stopPropagation())},t.prototype.getCurrentPos=function(){return{x:this.scrollBehaviorX.getCurrentPos(),y:this.scrollBehaviorY.getCurrentPos()}},t.prototype.refresh=function(){this.endTime=0},t.prototype.destroy=function(){this.hooks.destroy()},t}();function st(t,e,o,n){var r=["momentum","momentumLimitTime","momentumLimitDistance","deceleration","swipeBounceTime","swipeTime","outOfBoundaryDampingFactor","specifiedIndexAsContent"].reduce((function(e,o){return e[o]=t[o],e}),{});return r.scrollable=!!t[e],r.bounces=o,r.rect=n,r}function lt(t,e,o){o.forEach((function(o){var r,i;"string"==typeof o?r=i=o:(r=o.source,i=o.target),t.on(r,(function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return e.trigger.apply(e,n([i],t))}))}))}var ht=function(){function t(t,e,o){this.wrapper=t,this.content=e,this.resizeTimeout=0,this.hooks=new U(["beforeStart","beforeMove","beforeScrollStart","scrollStart","scroll","beforeEnd","scrollEnd","resize","touchEnd","end","flick","scrollCancel","momentum","scrollTo","minDistanceScroll","scrollToElement","beforeRefresh"]),this.options=o;var n,r=this.options.bounce,i=r.left,s=r.right,l=r.top,h=r.bottom;this.scrollBehaviorX=new et(t,e,st(o,"scrollX",[i,s],{size:"width",position:"left"})),this.scrollBehaviorY=new et(t,e,st(o,"scrollY",[l,h],{size:"height",position:"top"})),this.translater=new $(this.content),this.animater=function(t,e,o){var n=o.useTransition,r={};return Object.defineProperty(r,"probeType",{enumerable:!0,configurable:!1,get:function(){return o.probeType}}),n?new V(t,e,r):new Z(t,e,r)}(this.content,this.translater,this.options),this.actionsHandler=new I(this.options.bindToTarget?this.content:t,(n=this.options,["click","bindToWrapper","disableMouse","disableTouch","preventDefault","stopPropagation","tagException","preventDefaultException","autoEndDistance"].reduce((function(t,e){return t[e]=n[e],t}),{}))),this.actions=new it(this.scrollBehaviorX,this.scrollBehaviorY,this.actionsHandler,this.animater,this.options);var a=this.resize.bind(this);this.resizeRegister=new R(window,[{name:"orientationchange",handler:a},{name:"resize",handler:a}]),this.registerTransitionEnd(),this.init()}return t.prototype.init=function(){var t=this;this.bindTranslater(),this.bindAnimater(),this.bindActions(),this.hooks.on(this.hooks.eventTypes.scrollEnd,(function(){t.togglePointerEvents(!0)}))},t.prototype.registerTransitionEnd=function(){this.transitionEndRegister=new R(this.content,[{name:x.transitionEnd,handler:this.transitionEnd.bind(this)}])},t.prototype.bindTranslater=function(){var t=this,e=this.translater.hooks;e.on(e.eventTypes.beforeTranslate,(function(e){t.options.translateZ&&e.push(t.options.translateZ)})),e.on(e.eventTypes.translate,(function(e){var o=t.getCurrentPos();t.updatePositions(e),!0!==t.actions.ensuringInteger?e.x===o.x&&e.y===o.y||t.togglePointerEvents(!1):t.actions.ensuringInteger=!1}))},t.prototype.bindAnimater=function(){var t=this;this.animater.hooks.on(this.animater.hooks.eventTypes.end,(function(e){t.resetPosition(t.options.bounceTime)||(t.animater.setPending(!1),t.hooks.trigger(t.hooks.eventTypes.scrollEnd,e))})),lt(this.animater.hooks,this.hooks,[{source:this.animater.hooks.eventTypes.move,target:this.hooks.eventTypes.scroll},{source:this.animater.hooks.eventTypes.forceStop,target:this.hooks.eventTypes.scrollEnd}])},t.prototype.bindActions=function(){var t=this,e=this.actions;lt(e.hooks,this.hooks,[{source:e.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeStart},{source:e.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeScrollStart},{source:e.hooks.eventTypes.beforeMove,target:this.hooks.eventTypes.beforeMove},{source:e.hooks.eventTypes.scrollStart,target:this.hooks.eventTypes.scrollStart},{source:e.hooks.eventTypes.scroll,target:this.hooks.eventTypes.scroll},{source:e.hooks.eventTypes.beforeEnd,target:this.hooks.eventTypes.beforeEnd}]),e.hooks.on(e.hooks.eventTypes.end,(function(o,n){return t.hooks.trigger(t.hooks.eventTypes.touchEnd,n),!!t.hooks.trigger(t.hooks.eventTypes.end,n)||(!(e.fingerMoved||(t.hooks.trigger(t.hooks.eventTypes.scrollCancel),!t.checkClick(o)))||(t.resetPosition(t.options.bounceTime,L.bounce)?(t.animater.setForceStopped(!1),!0):void 0))})),e.hooks.on(e.hooks.eventTypes.scrollEnd,(function(o,n){var r=Math.abs(o.x-t.scrollBehaviorX.startPos),i=Math.abs(o.y-t.scrollBehaviorY.startPos);if(t.checkFlick(n,r,i))return t.animater.setForceStopped(!1),void t.hooks.trigger(t.hooks.eventTypes.flick);t.momentum(o,n)?t.animater.setForceStopped(!1):(e.contentMoved&&t.hooks.trigger(t.hooks.eventTypes.scrollEnd,o),t.animater.forceStopped&&t.animater.setForceStopped(!1))}))},t.prototype.checkFlick=function(t,e,o){if(this.hooks.events.flick.length>1&&t<this.options.flickLimitTime&&e<this.options.flickLimitDistance&&o<this.options.flickLimitDistance&&(o>1||e>1))return!0},t.prototype.momentum=function(t,e){var o={time:0,easing:L.swiper,newX:t.x,newY:t.y},n=this.scrollBehaviorX.end(e),r=this.scrollBehaviorY.end(e);if(o.newX=v(n.destination)?o.newX:n.destination,o.newY=v(r.destination)?o.newY:r.destination,o.time=Math.max(n.duration,r.duration),this.hooks.trigger(this.hooks.eventTypes.momentum,o,this),o.newX!==t.x||o.newY!==t.y)return(o.newX>this.scrollBehaviorX.minScrollPos||o.newX<this.scrollBehaviorX.maxScrollPos||o.newY>this.scrollBehaviorY.minScrollPos||o.newY<this.scrollBehaviorY.maxScrollPos)&&(o.easing=L.swipeBounce),this.scrollTo(o.newX,o.newY,o.time,o.easing),!0},t.prototype.checkClick=function(t){var e=this.animater.forceStopped;if(this.hooks.trigger(this.hooks.eventTypes.checkClick))return this.animater.setForceStopped(!1),!0;if(!e){var o=this.options.dblclick,n=!1;if(o&&this.lastClickTime){var r=o.delay,i=void 0===r?300:r;d()-this.lastClickTime<i&&(n=!0,function(t){Y(t,"dblclick")}(t))}return this.options.tap&&function(t,e){var o=document.createEvent("Event");o.initEvent(e,!0,!0),o.pageX=t.pageX,o.pageY=t.pageY,t.target.dispatchEvent(o)}(t,this.options.tap),this.options.click&&!O(t.target,this.options.preventDefaultException)&&Y(t),this.lastClickTime=n?null:d(),!0}return!1},t.prototype.resize=function(){var t=this;this.actions.enabled&&(a&&(this.wrapper.scrollTop=0),clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout((function(){t.hooks.trigger(t.hooks.eventTypes.resize)}),this.options.resizePolling))},t.prototype.transitionEnd=function(t){t.target===this.content&&this.animater.pending&&(this.animater.transitionTime(),this.resetPosition(this.options.bounceTime,L.bounce)||(this.animater.setPending(!1),3!==this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scrollEnd,this.getCurrentPos())))},t.prototype.togglePointerEvents=function(t){void 0===t&&(t=!0);for(var e=this.content.children.length?this.content.children:[this.content],o=t?"auto":"none",n=0;n<e.length;n++){var r=e[n];r.isBScrollContainer||(r.style.pointerEvents=o)}},t.prototype.refresh=function(t){var e=this.setContent(t);this.hooks.trigger(this.hooks.eventTypes.beforeRefresh),this.scrollBehaviorX.refresh(t),this.scrollBehaviorY.refresh(t),e&&(this.translater.setContent(t),this.animater.setContent(t),this.transitionEndRegister.destroy(),this.registerTransitionEnd(),this.options.bindToTarget&&this.actionsHandler.setContent(t)),this.actions.refresh(),this.wrapperOffset=S(this.wrapper)},t.prototype.setContent=function(t){var e=t!==this.content;return e&&(this.content=t),e},t.prototype.scrollBy=function(t,e,o,n){void 0===o&&(o=0);var r=this.getCurrentPos(),i=r.x,s=r.y;n=n||L.bounce,t+=i,e+=s,this.scrollTo(t,e,o,n)},t.prototype.scrollTo=function(t,e,n,r,i){void 0===n&&(n=0),void 0===r&&(r=L.bounce),void 0===i&&(i={start:{},end:{}});var s=this.options.useTransition?r.style:r.fn,l=this.getCurrentPos(),h=o({x:l.x,y:l.y},i.start),a=o({x:t,y:e},i.end);if(this.hooks.trigger(this.hooks.eventTypes.scrollTo,a),!function(t,e){for(var o=0,n=Object.keys(t);o<n.length;o++){var r=n[o];if(t[r]!==e[r])return!1}return!0}(h,a)){var c=Math.abs(a.x-h.x),p=Math.abs(a.y-h.y);c<1&&p<1&&(n=0,this.hooks.trigger(this.hooks.eventTypes.minDistanceScroll)),this.animater.move(h,a,n,s)}},t.prototype.scrollToElement=function(t,e,o,n,r){var i=T(t),s=S(i),l=function(t,e,o){return"number"==typeof t?t:t?Math.round(e/2-o/2):0};o=l(o,i.offsetWidth,this.wrapper.offsetWidth),n=l(n,i.offsetHeight,this.wrapper.offsetHeight);var h=function(t,e,o,n){return t-=e,t=n.adjustPosition(t-o)};s.left=h(s.left,this.wrapperOffset.left,o,this.scrollBehaviorX),s.top=h(s.top,this.wrapperOffset.top,n,this.scrollBehaviorY),this.hooks.trigger(this.hooks.eventTypes.scrollToElement,i,s)||this.scrollTo(s.left,s.top,e,r)},t.prototype.resetPosition=function(t,e){void 0===t&&(t=0),void 0===e&&(e=L.bounce);var o=this.scrollBehaviorX.checkInBoundary(),n=o.position,r=o.inBoundary,i=this.scrollBehaviorY.checkInBoundary(),s=i.position,l=i.inBoundary;return(!r||!l)&&(c&&this.reflow(),this.scrollTo(n,s,t,e),!0)},t.prototype.reflow=function(){this._reflow=this.content.offsetHeight},t.prototype.updatePositions=function(t){this.scrollBehaviorX.updatePosition(t.x),this.scrollBehaviorY.updatePosition(t.y)},t.prototype.getCurrentPos=function(){return this.actions.getCurrentPos()},t.prototype.enable=function(){this.actions.enabled=!0},t.prototype.disable=function(){_(this.animater.timer),this.actions.enabled=!1},t.prototype.destroy=function(){var t=this;["resizeRegister","transitionEndRegister","actionsHandler","actions","hooks","animater","translater","scrollBehaviorX","scrollBehaviorY"].forEach((function(e){return t[e].destroy()}))},t}(),at=function(t){function o(e,o){var n=t.call(this,["refresh","contentChanged","enable","disable","beforeScrollStart","scrollStart","scroll","scrollEnd","scrollCancel","touchEnd","flick","destroy"])||this,r=T(e);return r?(n.plugins={},n.options=(new K).merge(o).process(),n.setContent(r).valid?(n.hooks=new U(["refresh","enable","disable","destroy","beforeInitialScrollTo","contentChanged"]),n.init(r),n):n):(i("Can not resolve the wrapper DOM."),n)}return e(o,t),o.use=function(t){var e=t.pluginName;return o.plugins.some((function(e){return t===e.ctor}))?o:v(e)?(i("Plugin Class must specify plugin's name in static property by 'pluginName' field."),o):(o.pluginsMap[e]=!0,o.plugins.push({name:e,applyOrder:t.applyOrder,ctor:t}),o)},o.prototype.setContent=function(t){var e=!1,o=!0,n=t.children[this.options.specifiedIndexAsContent];return n?(e=this.content!==n)&&(this.content=n):(i("The wrapper need at least one child element to be content element to scroll."),o=!1),{valid:o,contentChanged:e}},o.prototype.init=function(t){var e=this;this.wrapper=t,t.isBScrollContainer=!0,this.scroller=new ht(t,this.content,this.options),this.scroller.hooks.on(this.scroller.hooks.eventTypes.resize,(function(){e.refresh()})),this.eventBubbling(),this.handleAutoBlur(),this.enable(),this.proxy(r),this.applyPlugins(),this.refreshWithoutReset(this.content);var o=this.options,n={x:o.startX,y:o.startY};this.hooks.trigger(this.hooks.eventTypes.beforeInitialScrollTo,n)||this.scroller.scrollTo(n.x,n.y)},o.prototype.applyPlugins=function(){var t=this,e=this.options;o.plugins.sort((function(t,e){var o,n=((o={}).pre=-1,o.post=1,o);return(t.applyOrder?n[t.applyOrder]:0)-(e.applyOrder?n[e.applyOrder]:0)})).forEach((function(o){var n=o.ctor;e[o.name]&&"function"==typeof n&&(t.plugins[o.name]=new n(t))}))},o.prototype.handleAutoBlur=function(){this.options.autoBlur&&this.on(this.eventTypes.beforeScrollStart,(function(){var t=document.activeElement;!t||"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName||t.blur()}))},o.prototype.eventBubbling=function(){lt(this.scroller.hooks,this,[this.eventTypes.beforeScrollStart,this.eventTypes.scrollStart,this.eventTypes.scroll,this.eventTypes.scrollEnd,this.eventTypes.scrollCancel,this.eventTypes.touchEnd,this.eventTypes.flick])},o.prototype.refreshWithoutReset=function(t){this.scroller.refresh(t),this.hooks.trigger(this.hooks.eventTypes.refresh,t),this.trigger(this.eventTypes.refresh,t)},o.prototype.proxy=function(t){var e=this;t.forEach((function(t){var o=t.key,n=t.sourceKey;!function(t,e,o){j.get=function(){return function(t,e){for(var o=e.split("."),n=0;n<o.length-1;n++)if("object"!=typeof(t=t[o[n]])||!t)return;var r=o.pop();return"function"==typeof t[r]?function(){return t[r].apply(t,arguments)}:t[r]}(this,e)},j.set=function(t){!function(t,e,o){for(var n,r=e.split("."),i=0;i<r.length-1;i++)t[n=r[i]]||(t[n]={}),t=t[n];t[r.pop()]=o}(this,e,t)},Object.defineProperty(t,o,j)}(e,n,o)}))},o.prototype.refresh=function(){var t=this.setContent(this.wrapper),e=t.contentChanged;if(t.valid){var o=this.content;this.refreshWithoutReset(o),e&&(this.hooks.trigger(this.hooks.eventTypes.contentChanged,o),this.trigger(this.eventTypes.contentChanged,o)),this.scroller.resetPosition()}},o.prototype.enable=function(){this.scroller.enable(),this.hooks.trigger(this.hooks.eventTypes.enable),this.trigger(this.eventTypes.enable)},o.prototype.disable=function(){this.scroller.disable(),this.hooks.trigger(this.hooks.eventTypes.disable),this.trigger(this.eventTypes.disable)},o.prototype.destroy=function(){this.hooks.trigger(this.hooks.eventTypes.destroy),this.trigger(this.eventTypes.destroy),this.scroller.destroy()},o.prototype.eventRegister=function(t){this.registerType(t)},o.plugins=[],o.pluginsMap={},o}(U);function ct(t,e){return new at(t,e)}ct.use=at.use,ct.plugins=at.plugins,ct.pluginsMap=at.pluginsMap;var pt=ct;
/*!
* better-scroll / mouse-wheel
* (c) 2016-2021 ustbhuangyi
* Released under the MIT License.
*/var ut="undefined"!=typeof window,dt=ut&&navigator.userAgent.toLowerCase();dt&&/wechatdevtools/.test(dt),dt&&dt.indexOf("android"),function(){if("string"==typeof dt){var t=/os (\d\d?_\d(_\d)?)/.exec(dt);if(!t)return!1;var e=t[1].split("_").map((function(t){return parseInt(t,10)}));return!!(13===e[0]&&e[1]>=4)}}();var ft=!1;if(ut){try{var vt={};Object.defineProperty(vt,"passive",{get:function(){ft=!0}}),window.addEventListener("test-passive",(function(){}),vt)}catch(t){}}var yt=ut&&document.createElement("div").style,mt=function(){if(!ut)return!1;for(var t=0,e=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];t<e.length;t++){var o=e[t];if(void 0!==yt[o.value])return o.key}return!1}();function gt(t){return!1===mt?t:"standard"===mt?"transitionEnd"===t?"transitionend":t:mt+t.charAt(0).toUpperCase()+t.substr(1)}function kt(t,e,o,n){var r=ft?{passive:!1,capture:!!n}:!!n;t.addEventListener(e,o,r)}function Tt(t,e,o,n){t.removeEventListener(e,o,{capture:!!n})}mt&&"standard"!==mt&&mt.toLowerCase();gt("transform"),gt("transition");ut&>("perspective"),gt("transitionTimingFunction"),gt("transitionDuration"),gt("transitionDelay"),gt("transformOrigin"),gt("transitionEnd"),gt("transitionProperty");var wt=function(){function t(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}return t.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},t.prototype.addDOMEvents=function(){this.handleDOMEvents(kt)},t.prototype.removeDOMEvents=function(){this.handleDOMEvents(Tt)},t.prototype.handleDOMEvents=function(t){var e=this,o=this.wrapper;this.events.forEach((function(n){t(o,n.name,e,!!n.capture)}))},t.prototype.handleEvent=function(t){var e=t.type;this.events.some((function(o){return o.name===e&&(o.handler(t),!0)}))},t}(),bt=function(){function t(t){this.scroll=t,this.wheelEndTimer=0,this.wheelMoveTimer=0,this.wheelStart=!1,this.init()}return t.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.registerEvent()},t.prototype.handleBScroll=function(){this.scroll.registerType(["alterOptions","mousewheelStart","mousewheelMove","mousewheelEnd"])},t.prototype.handleOptions=function(){var t=!0===this.scroll.options.mouseWheel?{}:this.scroll.options.mouseWheel;this.mouseWheelOpt=function(t,e){for(var o in e)t[o]=e[o];return t}({speed:20,invert:!1,easeTime:300,discreteTime:400,throttleTime:0,dampingFactor:.1},t)},t.prototype.handleHooks=function(){this.hooksFn=[],this.registerHooks(this.scroll.hooks,"destroy",this.destroy)},t.prototype.registerEvent=function(){this.eventRegister=new wt(this.scroll.scroller.wrapper,[{name:"wheel",handler:this.wheelHandler.bind(this)},{name:"mousewheel",handler:this.wheelHandler.bind(this)},{name:"DOMMouseScroll",handler:this.wheelHandler.bind(this)}])},t.prototype.registerHooks=function(t,e,o){t.on(e,o,this),this.hooksFn.push([t,e,o])},t.prototype.wheelHandler=function(t){if(this.scroll.enabled){this.beforeHandler(t),this.wheelStart||(this.wheelStartHandler(t),this.wheelStart=!0);var e=this.getWheelDelta(t);this.wheelMoveHandler(e),this.wheelEndDetector(e)}},t.prototype.wheelStartHandler=function(t){this.cleanCache();var e=this.scroll.scroller,o=e.scrollBehaviorX,n=e.scrollBehaviorY;o.setMovingDirection(0),n.setMovingDirection(0),o.setDirection(0),n.setDirection(0),this.scroll.trigger(this.scroll.eventTypes.alterOptions,this.mouseWheelOpt),this.scroll.trigger(this.scroll.eventTypes.mousewheelStart)},t.prototype.cleanCache=function(){this.deltaCache=[]},t.prototype.wheelMoveHandler=function(t){var e=this,o=this.mouseWheelOpt,n=o.throttleTime,r=o.dampingFactor;if(n&&this.wheelMoveTimer)this.deltaCache.push(t);else{var i=this.deltaCache.reduce((function(t,e){return{x:t.x+e.x,y:t.y+e.y}}),{x:0,y:0});this.cleanCache();var s=this.scroll.scroller,l=s.scrollBehaviorX,h=s.scrollBehaviorY;l.setMovingDirection(-t.directionX),h.setMovingDirection(-t.directionY),l.setDirection(t.x),h.setDirection(t.y);var a=l.performDampingAlgorithm(Math.round(t.x)+i.x,r),c=h.performDampingAlgorithm(Math.round(t.y)+i.x,r);if(!this.scroll.trigger(this.scroll.eventTypes.mousewheelMove,{x:a,y:c})){var p=this.getEaseTime();a===this.scroll.x&&c===this.scroll.y||this.scroll.scrollTo(a,c,p)}n&&(this.wheelMoveTimer=window.setTimeout((function(){e.wheelMoveTimer=0}),n))}},t.prototype.wheelEndDetector=function(t){var e=this;window.clearTimeout(this.wheelEndTimer),this.wheelEndTimer=window.setTimeout((function(){e.wheelStart=!1,window.clearTimeout(e.wheelMoveTimer),e.wheelMoveTimer=0,e.scroll.trigger(e.scroll.eventTypes.mousewheelEnd,t)}),this.mouseWheelOpt.discreteTime)},t.prototype.getWheelDelta=function(t){var e=this.mouseWheelOpt,o=e.speed,n=0,r=0,i=e.invert?-1:1;switch(!0){case"deltaX"in t:1===t.deltaMode?(n=-t.deltaX*o,r=-t.deltaY*o):(n=-t.deltaX,r=-t.deltaY);break;case"wheelDeltaX"in t:n=t.wheelDeltaX/120*o,r=t.wheelDeltaY/120*o;break;case"wheelDelta"in t:n=r=t.wheelDelta/120*o;break;case"detail"in t:n=r=-t.detail/3*o}return n*=i,r*=i,this.scroll.hasVerticalScroll||(Math.abs(r)>Math.abs(n)&&(n=r),r=0),this.scroll.hasHorizontalScroll||(n=0),{x:n,y:r,directionX:n>0?-1:n<0?1:0,directionY:r>0?-1:r<0?1:0}},t.prototype.beforeHandler=function(t){var e=this.scroll.options,o=e.preventDefault,n=e.stopPropagation,r=e.preventDefaultException;o&&!function(t,e){for(var o in e)if(e[o].test(t[o]))return!0;return!1}(t.target,r)&&t.preventDefault(),n&&t.stopPropagation()},t.prototype.getEaseTime=function(){var t,e=this.mouseWheelOpt.easeTime;return e<100&&(t="easeTime should be greater than 100.If mouseWheel easeTime is too small,scrollEnd will be triggered many times.",console.error("[BScroll warn]: "+t)),Math.max(e,100)},t.prototype.destroy=function(){this.eventRegister.destroy(),window.clearTimeout(this.wheelEndTimer),window.clearTimeout(this.wheelMoveTimer),this.hooksFn.forEach((function(t){var e=t[0],o=t[1],n=t[2];e.off(o,n)}))},t.pluginName="mouseWheel",t.applyOrder="pre",t}(),St="undefined"!=typeof window,Pt=St&&navigator.userAgent.toLowerCase();Pt&&/wechatdevtools/.test(Pt),Pt&&Pt.indexOf("android"),function(){if("string"==typeof Pt){var t=/os (\d\d?_\d(_\d)?)/.exec(Pt);if(!t)return!1;var e=t[1].split("_").map((function(t){return parseInt(t,10)}));return!!(13===e[0]&&e[1]>=4)}}();if(St){try{var Et={};Object.defineProperty(Et,"passive",{get:function(){!0}}),window.addEventListener("test-passive",(function(){}),Et)}catch(t){}}var Ct=St&&document.createElement("div").style,Bt=function(){if(!St)return!1;for(var t=0,e=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];t<e.length;t++){var o=e[t];if(void 0!==Ct[o.value])return o.key}return!1}();function Dt(t){return!1===Bt?t:"standard"===Bt?"transitionEnd"===t?"transitionend":t:Bt+t.charAt(0).toUpperCase()+t.substr(1)}Bt&&"standard"!==Bt&&Bt.toLowerCase();Dt("transform"),Dt("transition");St&&Dt("perspective"),Dt("transitionTimingFunction"),Dt("transitionDuration"),Dt("transitionDelay"),Dt("transformOrigin"),Dt("transitionEnd"),Dt("transitionProperty");var xt=[{key:"finishPullUp",name:"finishPullUp"},{key:"openPullUp",name:"openPullUp"},{key:"closePullUp",name:"closePullUp"},{key:"autoPullUpLoad",name:"autoPullUpLoad"}].map((function(t){return{key:t.key,sourceKey:"plugins.pullUpLoad."+t.name}})),Mt="pullingUp",At=function(){function t(t){this.scroll=t,this.pulling=!1,this.watching=!1,this.init()}return t.prototype.init=function(){this.handleBScroll(),this.handleOptions(this.scroll.options.pullUpLoad),this.handleHooks(),this.watch()},t.prototype.handleBScroll=function(){this.scroll.registerType([Mt]),this.scroll.proxy(xt)},t.prototype.handleOptions=function(t){void 0===t&&(t={}),t=!0===t?{}:t;this.options=function(t,e){for(var o in e)t[o]=e[o];return t}({threshold:0},t),this.scroll.options.probeType=3},t.prototype.handleHooks=function(){var t=this;this.hooksFn=[];var e=this.scroll.scroller.scrollBehaviorY;this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,(function(){t.finishPullUp()})),this.registerHooks(e.hooks,e.hooks.eventTypes.computeBoundary,(function(t){t.maxScrollPos>0&&(t.maxScrollPos=-1)}))},t.prototype.registerHooks=function(t,e,o){t.on(e,o,this),this.hooksFn.push([t,e,o])},t.prototype.watch=function(){this.watching||(this.watching=!0,this.registerHooks(this.scroll,this.scroll.eventTypes.scroll,this.checkPullUp))},t.prototype.unwatch=function(){this.watching=!1,this.scroll.off(this.scroll.eventTypes.scroll,this.checkPullUp)},t.prototype.checkPullUp=function(t){var e=this,o=this.options.threshold;1===this.scroll.movingDirectionY&&t.y<=this.scroll.maxScrollY+o&&(this.pulling=!0,this.scroll.once(this.scroll.eventTypes.scrollEnd,(function(){e.pulling=!1})),this.unwatch(),this.scroll.trigger(Mt))},t.prototype.finishPullUp=function(){var t=this;this.scroll.scroller.scrollBehaviorY.setMovingDirection(0),this.pulling?this.scroll.once(this.scroll.eventTypes.scrollEnd,(function(){t.watch()})):this.watch()},t.prototype.openPullUp=function(t){void 0===t&&(t={}),this.handleOptions(t),this.watch()},t.prototype.closePullUp=function(){this.unwatch()},t.prototype.autoPullUpLoad=function(){var t=this.options.threshold,e=this.scroll.scroller.scrollBehaviorY;if(!this.pulling&&this.watching){var o=e.maxScrollPos+t+-1;this.scroll.scroller.scrollBehaviorY.setMovingDirection(-1),this