better-scroll
Version:
Full-featured BetterScroll
1 lines • 111 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BetterScroll={})}(this,function(t){"use strict";var I=function(t,e){return(I=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)};function L(t,e){function o(){this.constructor=t}I(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var c=function(){return(c=Object.assign||function(t){for(var e,o=1,s=arguments.length;o<s;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function F(t,n,h,l){return new(h=h||Promise)(function(o,e){function s(t){try{r(l.next(t))}catch(t){e(t)}}function i(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?o(t.value):((e=t.value)instanceof h?e:new h(function(t){t(e)})).then(s,i)}r((l=l.apply(t,n||[])).next())})}function A(s,i){var r,n,h,l={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(o){return function(t){var e=[o,t];if(r)throw new TypeError("Generator is already executing.");for(;l;)try{if(r=1,n&&(h=2&e[0]?n.return:e[0]?n.throw||((h=n.return)&&h.call(n),0):n.next)&&!(h=h.call(n,e[1])).done)return h;switch(n=0,(e=h?[2&e[0],h.value]:e)[0]){case 0:case 1:h=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,n=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(h=0<(h=l.trys).length&&h[h.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!h||e[1]>h[0]&&e[1]<h[3]))l.label=e[1];else if(6===e[0]&&l.label<h[1])l.label=h[1],h=e;else{if(!(h&&l.label<h[2])){h[2]&&l.ops.pop(),l.trys.pop();continue}l.label=h[2],l.ops.push(e)}}e=i.call(s,l)}catch(t){e=[6,t],n=0}finally{r=h=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function N(){for(var t=0,e=0,o=arguments.length;e<o;e++)t+=arguments[e].length;for(var s=Array(t),i=0,e=0;e<o;e++)for(var r=arguments[e],n=0,h=r.length;n<h;n++,i++)s[i]=r[n];return s}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 s(t){console.error("[BScroll warn]: "+t)}function W(t,e){if(!t)throw new Error("[BScroll] "+e)}var i="undefined"!=typeof window,e=i&&navigator.userAgent.toLowerCase(),o=!(!e||!/wechatdevtools/.test(e)),K=e&&0<e.indexOf("android"),j="string"==typeof e&&(!!(e=/os (\d\d?_\d(_\d)?)/.exec(e))&&!!(13===(e=e[1].split("_").map(function(t){return parseInt(t,10)}))[0]&&4<=e[1])),U=!1;if(i)try{var r={};Object.defineProperty(r,"passive",{get:function(){U=!0}}),window.addEventListener("test-passive",function(){},r)}catch(t){}function d(){return window.performance&&window.performance.now&&window.performance.timing?window.performance.now()+window.performance.timing.navigationStart:+new Date}var n=function(t,e){for(var o in e)t[o]=e[o];return t};function _(t){return null==t}function g(t,e,o){return t<e?e:o<t?o:t}function V(t,s){var i;return t.findIndex?t.findIndex(s):(i=-1,t.some(function(t,e,o){t=s(t,e,o);if(t)return i=e,t}),i)}var Z=i&&document.createElement("div").style,q=function(){if(i)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!==Z[o.value])return o.key}return!1}();function h(t){return!1===q?t:"standard"===q?"transitionEnd"===t?"transitionend":t:q+t.charAt(0).toUpperCase()+t.substr(1)}function G(t){return"string"==typeof t?document.querySelector(t):t}function $(t,e,o,s){s=U?{passive:!1,capture:!!s}:!!s;t.addEventListener(e,o,s)}function J(t,e,o,s){t.removeEventListener(e,o,{capture:!!s})}function Q(t){t.cancelable&&t.preventDefault()}function tt(t){for(var e=0,o=0;t;)e-=t.offsetLeft,o-=t.offsetTop,t=t.offsetParent;return{left:e,top:o}}var et=q&&"standard"!==q?"-"+q.toLowerCase()+"-":"",e=h("transform"),r=h("transition"),ot=i&&h("perspective")in Z,st=i&&("ontouchstart"in window||o),it=i&&r in Z,p={transform:e,transition:r,transitionTimingFunction:h("transitionTimingFunction"),transitionDuration:h("transitionDuration"),transitionDelay:h("transitionDelay"),transformOrigin:h("transformOrigin"),transitionEnd:h("transitionEnd"),transitionProperty:h("transitionProperty")},rt={touchstart:1,touchmove:1,touchend:1,touchcancel:1,mousedown:2,mousemove:2,mouseup:2};function nt(t){var e;return t instanceof window.SVGElement?{top:(e=t.getBoundingClientRect()).top,left:e.left,width:e.width,height:e.height}:{top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth,height:t.offsetHeight}}function ht(t,e){for(var o in e)if(e[o].test(t[o]))return!0;return!1}var lt=ht;function at(t,e){void 0===e&&(e="click"),"mouseup"===t.type?i=t:"touchend"!==t.type&&"touchcancel"!==t.type||(i=t.changedTouches[0]);var o,s={},i=(i&&(s.screenX=i.screenX||0,s.screenY=i.screenY||0,s.clientX=i.clientX||0,s.clientY=i.clientY||0),{ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey});if("undefined"!=typeof MouseEvent)try{o=new MouseEvent(e,n(c({bubbles:!0,cancelable:!0},i),s))}catch(t){r()}else r();function r(){(o=document.createEvent("Event")).initEvent(e,!0,!0),n(o,s)}o.forwardedTouchEvent=!0,o._constructed=!0,t.target.dispatchEvent(o)}function ct(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)}var f={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}}},o=i&&window;function pt(){}function ut(t){}var dt=i?o.requestAnimationFrame||o.webkitRequestAnimationFrame||o.mozRequestAnimationFrame||o.oRequestAnimationFrame||function(t){return window.setTimeout(t,t.interval||1e3/60)}:pt,gt=i?o.cancelAnimationFrame||o.webkitCancelAnimationFrame||o.mozCancelAnimationFrame||o.oCancelAnimationFrame||function(t){window.clearTimeout(t)}:pt,ft={enumerable:!0,configurable:!0,get:ut,set:ut};function yt(t,r,e){ft.get=function(){for(var t=this,e=r.split("."),o=0;o<e.length-1;o++)if("object"!=typeof(t=t[e[o]])||!t)return;var s=e.pop();return"function"==typeof t[s]?function(){return t[s].apply(t,arguments)}:t[s]},ft.set=function(t){for(var e,o=this,s=r.split("."),i=0;i<s.length-1;i++)o[e=s[i]]||(o[e]={}),o=o[e];o[s.pop()]=t},Object.defineProperty(t,e,ft)}mt.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},mt.prototype.once=function(s,i,r){var n=this,h=(void 0===r&&(r=this),this.hasType(s),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];n.off(s,h);var o=i.apply(r,t);if(!0===o)return o});return h.fn=i,this.on(s,h),this},mt.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),e){var o=this.events[t];if(o)for(var s=o.length;s--;)(o[s][0]===e||o[s][0]&&o[s][0].fn===e)&&o.splice(s,1)}else this.events[t]=[];return this}},mt.prototype.trigger=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.hasType(t);t=this.events[t];if(t)for(var s=t.length,i=N(t),r=0;r<s;r++){var n=i[r],h=n[0],n=n[1];if(h&&!0===(h=h.apply(n,e)))return h}},mt.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},mt.prototype.destroy=function(){this.events={},this.eventTypes={}},mt.prototype.hasType=function(t){var e=this.eventTypes;e[t]!==t&&s('EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(e).map(function(t){return JSON.stringify(t)})+"]")};var a=mt;function mt(t){this.events={},this.eventTypes={},this.registerType(t)}vt.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},vt.prototype.addDOMEvents=function(){this.handleDOMEvents($)},vt.prototype.removeDOMEvents=function(){this.handleDOMEvents(J)},vt.prototype.handleDOMEvents=function(e){var o=this,s=this.wrapper;this.events.forEach(function(t){e(s,t.name,o,!!t.capture)})},vt.prototype.handleEvent=function(e){var o=e.type;this.events.some(function(t){return t.name===o&&(t.handler(e),!0)})};var u=vt;function vt(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}function kt(){}L(Pt,Tt=kt),Pt.prototype.merge=function(t){if(t)for(var e in t)"bounce"===e?this.bounce=this.resolveBounce(t[e]):this[e]=t[e];return this},Pt.prototype.process=function(){return this.translateZ=this.HWCompositing&&ot?" translateZ(1px)":"",this.useTransition=this.useTransition&&it,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},Pt.prototype.resolveBounce=function(t){var e={top:!0,right:!0,bottom:!0,left:!0},t="object"==typeof t?n(e,t):t?e:{top:!1,right:!1,bottom:!1,left:!1};return t};var Tt,St=Pt;function Pt(){var t=Tt.call(this)||this;return t.startX=0,t.startY=0,t.scrollX=!1,t.scrollY=!0,t.freeScroll=!1,t.directionLockThreshold=0,t.eventPassthrough="",t.click=!1,t.dblclick=!1,t.tap="",t.bounce={top:!0,bottom:!0,left:!0,right:!0},t.bounceTime=800,t.momentum=!0,t.momentumLimitTime=300,t.momentumLimitDistance=15,t.swipeTime=2500,t.swipeBounceTime=500,t.deceleration=.0015,t.flickLimitTime=200,t.flickLimitDistance=100,t.resizePolling=60,t.probeType=0,t.stopPropagation=!1,t.preventDefault=!0,t.preventDefaultException={tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/},t.tagException={tagName:/^TEXTAREA$/},t.HWCompositing=!0,t.useTransition=!0,t.bindToWrapper=!1,t.bindToTarget=!1,t.disableMouse=st,t.disableTouch=!st,t.autoBlur=!0,t.autoEndDistance=5,t.outOfBoundaryDampingFactor=1/3,t.specifiedIndexAsContent=0,t.quadrant=1,t}l.prototype.handleDOMEvents=function(){var t=this.options,e=t.bindToWrapper,o=t.disableMouse,s=t.disableTouch,t=t.click,i=this.wrapper,e=e?i:window,r=[],n=[],s=!s,o=!o;t&&r.push({name:"click",handler:this.click.bind(this),capture:!0}),s&&(r.push({name:"touchstart",handler:this.start.bind(this)}),n.push({name:"touchmove",handler:this.move.bind(this)},{name:"touchend",handler:this.end.bind(this)},{name:"touchcancel",handler:this.end.bind(this)})),o&&(r.push({name:"mousedown",handler:this.start.bind(this)}),n.push({name:"mousemove",handler:this.move.bind(this)},{name:"mouseup",handler:this.end.bind(this)})),this.wrapperEventRegister=new u(i,r),this.targetEventRegister=new u(e,n)},l.prototype.beforeHandler=function(t,e){var o=this.options,s=o.preventDefault,i=o.stopPropagation,r=o.preventDefaultException;!{start:function(){return s&&!ht(t.target,r)},end:function(){return s&&!ht(t.target,r)},move:function(){return s}}[e]()||t.preventDefault(),i&&t.stopPropagation()},l.prototype.setInitiated=function(t){this.initiated=t=void 0===t?0:t},l.prototype.start=function(t){var e=rt[t.type];this.initiated&&this.initiated!==e||(this.setInitiated(e),lt(t.target,this.options.tagException)?this.setInitiated():2===e&&0!==t.button||this.hooks.trigger(this.hooks.eventTypes.beforeStart,t)||(this.beforeHandler(t,"start"),e=t.touches?t.touches[0]:t,this.pointX=e.pageX,this.pointY=e.pageY,this.hooks.trigger(this.hooks.eventTypes.start,t)))},l.prototype.move=function(t){var e,o,s;rt[t.type]===this.initiated&&(this.beforeHandler(t,"move"),s=(o=t.touches?t.touches[0]:t).pageX-this.pointX,e=o.pageY-this.pointY,this.pointX=o.pageX,this.pointY=o.pageY,this.hooks.trigger(this.hooks.eventTypes.move,{deltaX:s,deltaY:e,e:t})||(o=document.documentElement.scrollLeft||window.pageXOffset||document.body.scrollLeft,s=document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop,e=this.pointX-o,o=this.pointY-s,s=this.options.autoEndDistance,(e>document.documentElement.clientWidth-s||o>document.documentElement.clientHeight-s||e<s||o<s)&&this.end(t)))},l.prototype.end=function(t){rt[t.type]===this.initiated&&(this.setInitiated(),this.beforeHandler(t,"end"),this.hooks.trigger(this.hooks.eventTypes.end,t))},l.prototype.click=function(t){this.hooks.trigger(this.hooks.eventTypes.click,t)},l.prototype.setContent=function(t){t!==this.wrapper&&(this.wrapper=t,this.rebindDOMEvents())},l.prototype.rebindDOMEvents=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.handleDOMEvents()},l.prototype.destroy=function(){this.wrapperEventRegister.destroy(),this.targetEventRegister.destroy(),this.hooks.destroy()};var bt=l;function l(t,e){this.wrapper=t,this.options=e,this.hooks=new a(["beforeStart","start","move","end","click"]),this.handleDOMEvents()}var wt={x:["translateX","px"],y:["translateY","px"]},xt=(Mt.prototype.getComputedPosition=function(){var t=window.getComputedStyle(this.content,null)[p.transform].split(")")[0].split(", ");return{x:+(t[12]||t[4])||0,y:+(t[13]||t[5])||0}},Mt.prototype.translate=function(s){var i=[];Object.keys(s).forEach(function(t){var e,o;!wt[t]||(e=wt[t][0])&&(o=wt[t][1],t=s[t],i.push(e+"("+t+o+")"))}),this.hooks.trigger(this.hooks.eventTypes.beforeTranslate,i,s),this.style[p.transform]=i.join(" "),this.hooks.trigger(this.hooks.eventTypes.translate,s)},Mt.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style)},Mt.prototype.destroy=function(){this.hooks.destroy()},Mt);function Mt(t){this.setContent(t),this.hooks=new a(["beforeTranslate","translate"])}Yt.prototype.translate=function(t){this.translater.translate(t)},Yt.prototype.setPending=function(t){this.pending=t},Yt.prototype.setForceStopped=function(t){this.forceStopped=t},Yt.prototype.setCallStop=function(t){this.callStopWhenPending=t},Yt.prototype.setContent=function(t){this.content!==t&&(this.content=t,this.style=t.style,this.stop())},Yt.prototype.clearTimer=function(){this.timer&&(gt(this.timer),this.timer=0)},Yt.prototype.destroy=function(){this.hooks.destroy(),gt(this.timer)};e=Yt;function Yt(t,e,o){this.translater=e,this.options=o,this.timer=0,this.hooks=new a(["move","end","beforeForceStop","forceStop","callStop","time","timeFunction"]),this.setContent(t)}function Bt(t,e,o,s){function i(t,e){return 0<(t-=e)?-1:t<0?1:0}var r=i(e.x,t.x),e=i(e.y,t.y),t=o.x-s.x,o=o.y-s.y;return r*t<=0&&e*o<=0}L(y,Et=e),y.prototype.startProbe=function(e,o){var s=this,i=e,r=function(){var t=s.translater.getComputedPosition();Bt(e,o,t,i)&&s.hooks.trigger(s.hooks.eventTypes.move,t),s.pending||(s.callStopWhenPending?s.callStopWhenPending=!1:s.hooks.trigger(s.hooks.eventTypes.end,t)),i=t,s.pending&&(s.timer=dt(r))};this.callStopWhenPending&&this.setCallStop(!1),gt(this.timer),r()},y.prototype.transitionTime=function(t){this.style[p.transitionDuration]=(t=void 0===t?0:t)+"ms",this.hooks.trigger(this.hooks.eventTypes.time,t)},y.prototype.transitionTimingFunction=function(t){this.style[p.transitionTimingFunction]=t,this.hooks.trigger(this.hooks.eventTypes.timeFunction,t)},y.prototype.transitionProperty=function(){this.style[p.transitionProperty]=p.transform},y.prototype.move=function(t,e,o,s){this.setPending(0<o),this.transitionTimingFunction(s),this.transitionProperty(),this.transitionTime(o),this.translate(e);s=3===this.options.probeType;o&&s&&this.startProbe(t,e),o||(this._reflow=this.content.offsetHeight,s&&this.hooks.trigger(this.hooks.eventTypes.move,e),this.hooks.trigger(this.hooks.eventTypes.end,e))},y.prototype.doStop=function(){var t,e,o=this.pending;return this.setForceStopped(!1),this.setCallStop(!1),o&&(this.setPending(!1),gt(this.timer),t=(e=this.translater.getComputedPosition()).x,e=e.y,this.transitionTime(),this.translate({x:t,y:e}),this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,{x:t,y:e})),o},y.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)};var Et,Xt=y;function y(){return null!==Et&&Et.apply(this,arguments)||this}L(Ht,Ot=e),Ht.prototype.move=function(t,e,o,s){o?this.animate(t,e,o,s):(this.translate(e),3===this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.move,e),this.hooks.trigger(this.hooks.eventTypes.end,e))},Ht.prototype.animate=function(r,n,e,o){var h=this,l=d(),a=l+e,c=3===this.options.probeType,p=function(){var s,i,t=d();a<=t?(h.translate(n),c&&h.hooks.trigger(h.hooks.eventTypes.move,n),h.hooks.trigger(h.hooks.eventTypes.end,n)):(s=o((t-l)/e),i={},Object.keys(n).forEach(function(t){var e=r[t],o=n[t];i[t]=(o-e)*s+e}),h.translate(i),c&&h.hooks.trigger(h.hooks.eventTypes.move,i),h.pending&&(h.timer=dt(p)),h.pending||(h.callStopWhenPending?h.callStopWhenPending=!1:h.hooks.trigger(h.hooks.eventTypes.end,n)))};this.setPending(!0),this.callStopWhenPending&&this.setCallStop(!1),gt(this.timer),p()},Ht.prototype.doStop=function(){var t,e=this.pending;return this.setForceStopped(!1),this.setCallStop(!1),e&&(this.setPending(!1),gt(this.timer),t=this.translater.getComputedPosition(),this.setForceStopped(!0),this.setCallStop(!0),this.hooks.trigger(this.hooks.eventTypes.forceStop,t)),e},Ht.prototype.stop=function(){this.doStop()&&this.hooks.trigger(this.hooks.eventTypes.callStop)};var Ot,Dt=Ht;function Ht(){return null!==Ot&&Ot.apply(this,arguments)||this}m.prototype.start=function(){this.dist=0,this.setMovingDirection(0),this.setDirection(0)},m.prototype.move=function(t){return t=this.hasScroll?t:0,this.setMovingDirection(t),this.performDampingAlgorithm(t,this.options.outOfBoundaryDampingFactor)},m.prototype.setMovingDirection=function(t){this.movingDirection=0<t?-1:t<0?1:0},m.prototype.setDirection=function(t){this.direction=0<t?-1:t<0?1:0},m.prototype.performDampingAlgorithm=function(t,e){var o=this.currentPos+t;return o=o>this.minScrollPos||o<this.maxScrollPos?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},m.prototype.end=function(t){var e={duration:0},o=Math.abs(this.currentPos-this.startPos);return this.options.momentum&&t<this.options.momentumLimitTime&&o>this.options.momentumLimitDistance?(o=-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,o,this.options):{destination:this.currentPos,duration:0}):this.hooks.trigger(this.hooks.eventTypes.end,e),e},m.prototype.momentum=function(t,e,o,s,i,r,n){void 0===n&&(n=this.options);var e=t-e,o=Math.abs(e)/o,h=n.deceleration,l=n.swipeBounceTime,n=n.swipeTime,t={destination:t+o*o/h*(e<0?-1:1),duration:Math.min(n,2*o/h),rate:15};return this.hooks.trigger(this.hooks.eventTypes.momentum,t,e),t.destination<s?(t.destination=r?Math.max(s-r/4,s-r/t.rate*o):s,t.duration=l):t.destination>i&&(t.destination=r?Math.min(i+r/4,i+r/t.rate*o):i,t.duration=l),t.destination=Math.round(t.destination),t},m.prototype.updateDirection=function(){var t=this.currentPos-this.absStartPos;this.setDirection(t)},m.prototype.refresh=function(t){var e=this.options.rect,o=e.size,e=e.position,s="static"===window.getComputedStyle(this.wrapper,null).position,i=nt(this.wrapper),t=(this.wrapperSize=this.wrapper["width"===o?"clientWidth":"clientHeight"],this.setContent(t),nt(this.content));this.contentSize=t[o],this.relativeOffset=t[e],s&&(this.relativeOffset-=i[e]),this.computeBoundary(),this.setDirection(0)},m.prototype.setContent=function(t){t!==this.content&&(this.content=t,this.resetState())},m.prototype.resetState=function(){this.currentPos=0,this.startPos=0,this.dist=0,this.setDirection(0),this.setMovingDirection(0),this.resetStartPos()},m.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)},m.prototype.updatePosition=function(t){this.currentPos=t},m.prototype.getCurrentPos=function(){return this.currentPos},m.prototype.checkInBoundary=function(){var t=this.adjustPosition(this.currentPos);return{position:t,inBoundary:t===this.getCurrentPos()}},m.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},m.prototype.updateStartPos=function(){this.startPos=this.currentPos},m.prototype.updateAbsStartPos=function(){this.absStartPos=this.currentPos},m.prototype.resetStartPos=function(){this.updateStartPos(),this.updateAbsStartPos()},m.prototype.getAbsDist=function(t){return this.dist+=t,Math.abs(this.dist)},m.prototype.destroy=function(){this.hooks.destroy()};var Ct=m;function m(t,e,o){this.wrapper=t,this.options=o,this.hooks=new a(["beforeComputeBoundary","computeBoundary","momentum","end","ignoreHasScroll"]),this.refresh(e)}(r={}).yes=function(t){return!0},r.no=function(t){return Q(t),!1};var zt=r,It=((o={}).horizontal=((e={}).yes="horizontal",e.no="vertical",e),o.vertical=((r={}).yes="vertical",r.no="horizontal",r),o),Lt=(Ft.prototype.reset=function(){this.directionLocked=""},Ft.prototype.checkMovingDirection=function(t,e,o){return this.computeDirectionLock(t,e),this.handleEventPassthrough(o)},Ft.prototype.adjustDelta=function(t,e){return"horizontal"===this.directionLocked?e=0:"vertical"===this.directionLocked&&(t=0),{deltaX:t,deltaY:e}},Ft.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")},Ft.prototype.handleEventPassthrough=function(t){var e=It[this.directionLocked];if(e){if(this.eventPassthrough===e.yes)return zt.yes(t);if(this.eventPassthrough===e.no)return zt.no(t)}return!1},Ft);function Ft(t,e,o){this.directionLockThreshold=t,this.freeScroll=e,this.eventPassthrough=o,this.reset()}v.prototype.bindActionsHandler=function(){var i=this;this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start,function(t){return!i.enabled||i.handleStart(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move,function(t){var e,o=t.deltaX,s=t.deltaY,t=t.e;return!i.enabled||(o=o,s=s,e=2===(e=i.options.quadrant)?[s,-o]:3===e?[-o,-s]:4===e?[-s,o]:[o,s],i.hooks.trigger(i.hooks.eventTypes.coordinateTransformation,o={deltaX:e[0],deltaY:e[1]}),i.handleMove(o.deltaX,o.deltaY,t))}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end,function(t){return!i.enabled||i.handleEnd(t)}),this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click,function(t){i.enabled&&!t._constructed&&i.handleClick(t)})},v.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)},v.prototype.handleMove=function(t,e,o){var s,i,r;if(!this.hooks.trigger(this.hooks.eventTypes.beforeMove,o))return r=this.scrollBehaviorX.getAbsDist(t),i=this.scrollBehaviorY.getAbsDist(e),s=d(),!!this.checkMomentum(r,i,s)||(this.directionLockAction.checkMovingDirection(r,i,o)?(this.actionsHandler.setInitiated(),!0):(r=this.directionLockAction.adjustDelta(t,e),i=this.scrollBehaviorX.getCurrentPos(),o=this.scrollBehaviorX.move(r.deltaX),t=this.scrollBehaviorY.getCurrentPos(),e=this.scrollBehaviorY.move(r.deltaY),void(this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)||(this.fingerMoved||(this.fingerMoved=!0),r=o!==i||e!==t,this.contentMoved||r||this.hooks.trigger(this.hooks.eventTypes.contentNotMoved),!this.contentMoved&&r&&(this.contentMoved=!0,this.hooks.trigger(this.hooks.eventTypes.scrollStart)),this.contentMoved&&r&&(this.animater.translate({x:o,y:e}),this.dispatchScroll(s))))))},v.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())),1<this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scroll,this.getCurrentPos())},v.prototype.checkMomentum=function(t,e,o){return o-this.endTime>this.options.momentumLimitTime&&e<this.options.momentumLimitDistance&&t<this.options.momentumLimitDistance},v.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();t=this.endTime-this.startTime;this.hooks.trigger(this.hooks.eventTypes.scrollEnd,e,t)}},v.prototype.ensureIntegerPos=function(t){this.ensuringInteger=!0;var e=t.x,t=t.y,o=this.scrollBehaviorX,s=o.minScrollPos,o=o.maxScrollPos,i=this.scrollBehaviorY,r=i.minScrollPos,i=i.maxScrollPos,e=0<e?Math.ceil(e):Math.floor(e),t=0<t?Math.ceil(t):Math.floor(t);return{x:g(e,o,s),y:g(t,i,r)}},v.prototype.handleClick=function(t){ht(t.target,this.options.preventDefaultException)||(Q(t),t.stopPropagation())},v.prototype.getCurrentPos=function(){return{x:this.scrollBehaviorX.getCurrentPos(),y:this.scrollBehaviorY.getCurrentPos()}},v.prototype.refresh=function(){this.endTime=0},v.prototype.destroy=function(){this.hooks.destroy()};var At=v;function v(t,e,o,s,i){this.hooks=new a(["start","beforeMove","scrollStart","scroll","beforeEnd","end","scrollEnd","contentNotMoved","detectMovingDirection","coordinateTransformation"]),this.scrollBehaviorX=t,this.scrollBehaviorY=e,this.actionsHandler=o,this.animater=s,this.options=i,this.directionLockAction=new Lt(i.directionLockThreshold,i.freeScroll,i.eventPassthrough),this.enabled=!0,this.bindActionsHandler()}function Nt(o,t,e,s){var i=["momentum","momentumLimitTime","momentumLimitDistance","deceleration","swipeBounceTime","swipeTime","outOfBoundaryDampingFactor","specifiedIndexAsContent"].reduce(function(t,e){return t[e]=o[e],t},{});return i.scrollable=!!o[t],i.bounces=e,i.rect=s,i}function Rt(s,i,t){t.forEach(function(t){var e,o;"string"==typeof t?e=o=t:(e=t.source,o=t.target),s.on(e,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.trigger.apply(i,N([o],t))})})}k.prototype.init=function(){var t=this;this.bindTranslater(),this.bindAnimater(),this.bindActions(),this.hooks.on(this.hooks.eventTypes.scrollEnd,function(){t.togglePointerEvents(!0)})},k.prototype.registerTransitionEnd=function(){this.transitionEndRegister=new u(this.content,[{name:p.transitionEnd,handler:this.transitionEnd.bind(this)}])},k.prototype.bindTranslater=function(){var o=this,t=this.translater.hooks;t.on(t.eventTypes.beforeTranslate,function(t){o.options.translateZ&&t.push(o.options.translateZ)}),t.on(t.eventTypes.translate,function(t){var e=o.getCurrentPos();o.updatePositions(t),!0===o.actions.ensuringInteger?o.actions.ensuringInteger=!1:t.x===e.x&&t.y===e.y||o.togglePointerEvents(!1)})},k.prototype.bindAnimater=function(){var e=this;this.animater.hooks.on(this.animater.hooks.eventTypes.end,function(t){e.resetPosition(e.options.bounceTime)||(e.animater.setPending(!1),e.hooks.trigger(e.hooks.eventTypes.scrollEnd,t))}),Rt(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}])},k.prototype.bindActions=function(){var i=this,r=this.actions;Rt(r.hooks,this.hooks,[{source:r.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeStart},{source:r.hooks.eventTypes.start,target:this.hooks.eventTypes.beforeScrollStart},{source:r.hooks.eventTypes.beforeMove,target:this.hooks.eventTypes.beforeMove},{source:r.hooks.eventTypes.scrollStart,target:this.hooks.eventTypes.scrollStart},{source:r.hooks.eventTypes.scroll,target:this.hooks.eventTypes.scroll},{source:r.hooks.eventTypes.beforeEnd,target:this.hooks.eventTypes.beforeEnd}]),r.hooks.on(r.hooks.eventTypes.end,function(t,e){return i.hooks.trigger(i.hooks.eventTypes.touchEnd,e),!!i.hooks.trigger(i.hooks.eventTypes.end,e)||(!(r.fingerMoved||(i.hooks.trigger(i.hooks.eventTypes.scrollCancel),!i.checkClick(t)))||(i.resetPosition(i.options.bounceTime,f.bounce)?(i.animater.setForceStopped(!1),!0):void 0))}),r.hooks.on(r.hooks.eventTypes.scrollEnd,function(t,e){var o=Math.abs(t.x-i.scrollBehaviorX.startPos),s=Math.abs(t.y-i.scrollBehaviorY.startPos);i.checkFlick(e,o,s)?(i.animater.setForceStopped(!1),i.hooks.trigger(i.hooks.eventTypes.flick)):(i.momentum(t,e)||(r.contentMoved&&i.hooks.trigger(i.hooks.eventTypes.scrollEnd,t),i.animater.forceStopped))&&i.animater.setForceStopped(!1)})},k.prototype.checkFlick=function(t,e,o){if(1<this.hooks.events.flick.length&&t<this.options.flickLimitTime&&e<this.options.flickLimitDistance&&o<this.options.flickLimitDistance&&(1<o||1<e))return!0},k.prototype.momentum=function(t,e){var o={time:0,easing:f.swiper,newX:t.x,newY:t.y},s=this.scrollBehaviorX.end(e),e=this.scrollBehaviorY.end(e);if(o.newX=_(s.destination)?o.newX:s.destination,o.newY=_(e.destination)?o.newY:e.destination,o.time=Math.max(s.duration,e.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=f.swipeBounce),this.scrollTo(o.newX,o.newY,o.time,o.easing),!0},k.prototype.checkClick=function(t){var e,o,s,i=this.animater.forceStopped;return this.hooks.trigger(this.hooks.eventTypes.checkClick)?(this.animater.setForceStopped(!1),!0):!i&&(i=!1,(e=this.options.dblclick)&&this.lastClickTime&&(e=void 0===(e=e.delay)?300:e,d()-this.lastClickTime<e&&(i=!0,at(t,"dblclick"))),this.options.tap&&(e=t,o=this.options.tap,(s=document.createEvent("Event")).initEvent(o,!0,!0),s.pageX=e.pageX,s.pageY=e.pageY,e.target.dispatchEvent(s)),this.options.click&&!ht(t.target,this.options.preventDefaultException)&&at(t),this.lastClickTime=i?null:d(),!0)},k.prototype.resize=function(){var t=this;this.actions.enabled&&(K&&(this.wrapper.scrollTop=0),clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(function(){t.hooks.trigger(t.hooks.eventTypes.resize)},this.options.resizePolling))},k.prototype.transitionEnd=function(t){t.target===this.content&&this.animater.pending&&(this.animater.transitionTime(),this.resetPosition(this.options.bounceTime,f.bounce)||(this.animater.setPending(!1),3!==this.options.probeType&&this.hooks.trigger(this.hooks.eventTypes.scrollEnd,this.getCurrentPos())))},k.prototype.togglePointerEvents=function(t){for(var e=this.content.children.length?this.content.children:[this.content],o=(t=void 0===t?!0:t)?"auto":"none",s=0;s<e.length;s++){var i=e[s];i.isBScrollContainer||(i.style.pointerEvents=o)}},k.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=tt(this.wrapper)},k.prototype.setContent=function(t){var e=t!==this.content;return e&&(this.content=t),e},k.prototype.scrollBy=function(t,e,o,s){void 0===o&&(o=0);var i=this.getCurrentPos(),r=i.x,i=i.y;this.scrollTo(t+=r,e+=i,o,s=s||f.bounce)},k.prototype.scrollTo=function(t,e,o,s,i){void 0===o&&(o=0),void 0===s&&(s=f.bounce),void 0===i&&(i={start:{},end:{}});var s=this.options.useTransition?s.style:s.fn,r=this.getCurrentPos(),r=c({x:r.x,y:r.y},i.start),t=c({x:t,y:e},i.end);this.hooks.trigger(this.hooks.eventTypes.scrollTo,t),function(t,e){for(var o=0,s=Object.keys(t);o<s.length;o++){var i=s[o];if(t[i]!==e[i])return}return 1}(r,t)||(e=Math.abs(t.x-r.x),i=Math.abs(t.y-r.y),e<1&&i<1&&(o=0,this.hooks.trigger(this.hooks.eventTypes.minDistanceScroll)),this.animater.move(r,t,o,s))},k.prototype.scrollToElement=function(t,e,o,s,i){function r(t,e,o){return"number"==typeof t?t:t?Math.round(e/2-o/2):0}function n(t,e,o,s){return t=s.adjustPosition((t-=e)-o)}var t=G(t),h=tt(t);o=r(o,t.offsetWidth,this.wrapper.offsetWidth),s=r(s,t.offsetHeight,this.wrapper.offsetHeight);h.left=n(h.left,this.wrapperOffset.left,o,this.scrollBehaviorX),h.top=n(h.top,this.wrapperOffset.top,s,this.scrollBehaviorY),this.hooks.trigger(this.hooks.eventTypes.scrollToElement,t,h)||this.scrollTo(h.left,h.top,e,i)},k.prototype.resetPosition=function(t,e){void 0===t&&(t=0),void 0===e&&(e=f.bounce);var o=this.scrollBehaviorX.checkInBoundary(),s=o.position,o=o.inBoundary,i=this.scrollBehaviorY.checkInBoundary(),r=i.position,i=i.inBoundary;return(!o||!i)&&(j&&this.reflow(),this.scrollTo(s,r,t,e),!0)},k.prototype.reflow=function(){this._reflow=this.content.offsetHeight},k.prototype.updatePositions=function(t){this.scrollBehaviorX.updatePosition(t.x),this.scrollBehaviorY.updatePosition(t.y)},k.prototype.getCurrentPos=function(){return this.actions.getCurrentPos()},k.prototype.enable=function(){this.actions.enabled=!0},k.prototype.disable=function(){gt(this.animater.timer),this.actions.enabled=!1},k.prototype.destroy=function(){var e=this;["resizeRegister","transitionEndRegister","actionsHandler","actions","hooks","animater","translater","scrollBehaviorX","scrollBehaviorY"].forEach(function(t){return e[t].destroy()})};var Wt=k;function k(t,e,o){this.wrapper=t,this.content=e,this.resizeTimeout=0,this.hooks=new a(["beforeStart","beforeMove","beforeScrollStart","scrollStart","scroll","beforeEnd","scrollEnd","resize","touchEnd","end","flick","scrollCancel","momentum","scrollTo","minDistanceScroll","scrollToElement","beforeRefresh"]),this.options=o;var s,i,r=this.options.bounce,n=r.left,h=r.right,l=r.top,r=r.bottom,l=(this.scrollBehaviorX=new Ct(t,e,Nt(o,"scrollX",[n,h],{size:"width",position:"left"})),this.scrollBehaviorY=new Ct(t,e,Nt(o,"scrollY",[l,r],{size:"height",position:"top"})),this.translater=new xt(this.content),this.animater=(n=this.content,h=this.translater,s=this.options,e=s.useTransition,o={},Object.defineProperty(o,"probeType",{enumerable:!0,configurable:!1,get:function(){return s.probeType}}),new(e?Xt:Dt)(n,h,o)),this.actionsHandler=new bt(this.options.bindToTarget?this.content:t,(i=this.options,["click","bindToWrapper","disableMouse","disableTouch","preventDefault","stopPropagation","tagException","preventDefaultException","autoEndDistance"].reduce(function(t,e){return t[e]=i[e],t},{}))),this.actions=new At(this.scrollBehaviorX,this.scrollBehaviorY,this.actionsHandler,this.animater,this.options),this.resize.bind(this));this.resizeRegister=new u(window,[{name:"orientationchange",handler:l},{name:"resize",handler:l}]),this.registerTransitionEnd(),this.init()}L(T,Kt=a),T.use=function(e){var t=e.pluginName;return T.plugins.some(function(t){return e===t.ctor})||(_(t)?s("Plugin Class must specify plugin's name in static property by 'pluginName' field."):(T.pluginsMap[t]=!0,T.plugins.push({name:t,applyOrder:e.applyOrder,ctor:e}))),T},T.prototype.setContent=function(t){var e=!1,o=!0,t=t.children[this.options.specifiedIndexAsContent];return t?(e=this.content!==t)&&(this.content=t):(s("The wrapper need at least one child element to be content element to scroll."),o=!1),{valid:o,contentChanged:e}},T.prototype.init=function(t){var e=this,t=((this.wrapper=t).isBScrollContainer=!0,this.scroller=new Wt(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),this.options),t={x:t.startX,y:t.startY};this.hooks.trigger(this.hooks.eventTypes.beforeInitialScrollTo,t)||this.scroller.scrollTo(t.x,t.y)},T.prototype.applyPlugins=function(){var o=this,s=this.options;T.plugins.sort(function(t,e){var o={pre:-1,post:1};return(t.applyOrder?o[t.applyOrder]:0)-(e.applyOrder?o[e.applyOrder]:0)}).forEach(function(t){var e=t.ctor;s[t.name]&&"function"==typeof e&&(o.plugins[t.name]=new e(o))})},T.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()})},T.prototype.eventBubbling=function(){Rt(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])},T.prototype.refreshWithoutReset=function(t){this.scroller.refresh(t),this.hooks.trigger(this.hooks.eventTypes.refresh,t),this.trigger(this.eventTypes.refresh,t)},T.prototype.proxy=function(t){var o=this;t.forEach(function(t){var e=t.key,t=t.sourceKey;yt(o,t,e)})},T.prototype.refresh=function(){var t=this.setContent(this.wrapper),e=t.contentChanged;t.valid&&(t=this.content,this.refreshWithoutReset(t),e&&(this.hooks.trigger(this.hooks.eventTypes.contentChanged,t),this.trigger(this.eventTypes.contentChanged,t)),this.scroller.resetPosition())},T.prototype.enable=function(){this.scroller.enable(),this.hooks.trigger(this.hooks.eventTypes.enable),this.trigger(this.eventTypes.enable)},T.prototype.disable=function(){this.scroller.disable(),this.hooks.trigger(this.hooks.eventTypes.disable),this.trigger(this.eventTypes.disable)},T.prototype.destroy=function(){this.hooks.trigger(this.hooks.eventTypes.destroy),this.trigger(this.eventTypes.destroy),this.scroller.destroy()},T.prototype.eventRegister=function(t){this.registerType(t)},T.plugins=[],T.pluginsMap={};var Kt,jt=T;function T(t,e){var o=Kt.call(this,["refresh","contentChanged","enable","disable","beforeScrollStart","scrollStart","scroll","scrollEnd","scrollCancel","touchEnd","flick","destroy"])||this,t=G(t);return t?(o.plugins={},o.options=(new St).merge(e).process(),o.setContent(t).valid&&(o.hooks=new a(["refresh","enable","disable","destroy","beforeInitialScrollTo","contentChanged"]),o.init(t))):s("Can not resolve the wrapper DOM."),o}function Ut(t,e){return new jt(t,e)}Ut.use=jt.use,Ut.plugins=jt.plugins,Ut.pluginsMap=jt.pluginsMap;e=Ut,S.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.registerEvent()},S.prototype.handleBScroll=function(){this.scroll.registerType(["alterOptions","mousewheelStart","mousewheelMove","mousewheelEnd"])},S.prototype.handleOptions=function(){var t=!0===this.scroll.options.mouseWheel?{}:this.scroll.options.mouseWheel;this.mouseWheelOpt=n({speed:20,invert:!1,easeTime:300,discreteTime:400,throttleTime:0,dampingFactor:.1},t)},S.prototype.handleHooks=function(){this.hooksFn=[],this.registerHooks(this.scroll.hooks,"destroy",this.destroy)},S.prototype.registerEvent=function(){this.eventRegister=new u(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)}])},S.prototype.registerHooks=function(t,e,o){t.on(e,o,this),this.hooksFn.push([t,e,o])},S.prototype.wheelHandler=function(t){this.scroll.enabled&&(this.beforeHandler(t),this.wheelStart||(this.wheelStartHandler(t),this.wheelStart=!0),t=this.getWheelDelta(t),this.wheelMoveHandler(t),this.wheelEndDetector(t))},S.prototype.wheelStartHandler=function(t){this.cleanCache();var e=this.scroll.scroller,o=e.scrollBehaviorX,e=e.scrollBehaviorY;o.setMovingDirection(0),e.setMovingDirection(0),o.setDirection(0),e.setDirection(0),this.scroll.trigger(this.scroll.eventTypes.alterOptions,this.mouseWheelOpt),this.scroll.trigger(this.scroll.eventTypes.mousewheelStart)},S.prototype.cleanCache=function(){this.deltaCache=[]},S.prototype.wheelMoveHandler=function(t){var e,o,s,i=this,r=this.mouseWheelOpt,n=r.throttleTime,r=r.dampingFactor;n&&this.wheelMoveTimer?this.deltaCache.push(t):(e=this.deltaCache.reduce(function(t,e){return{x:t.x+e.x,y:t.y+e.y}},{x:0,y:0}),this.cleanCache(),o=(s=this.scroll.scroller).scrollBehaviorX,s=s.scrollBehaviorY,o.setMovingDirection(-t.directionX),s.setMovingDirection(-t.directionY),o.setDirection(t.x),s.setDirection(t.y),o=o.performDampingAlgorithm(Math.round(t.x)+e.x,r),s=s.performDampingAlgorithm(Math.round(t.y)+e.x,r),this.scroll.trigger(this.scroll.eventTypes.mousewheelMove,{x:o,y:s})||(t=this.getEaseTime(),o===this.scroll.x&&s===this.scroll.y||this.scroll.scrollTo(o,s,t)),n&&(this.wheelMoveTimer=window.setTimeout(function(){i.wheelMoveTimer=0},n)))},S.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)},S.prototype.getWheelDelta=function(t){var e=this.mouseWheelOpt,o=e.speed,s=0,i=0,e=e.invert?-1:1;switch(!0){case"deltaX"in t:i=1===t.deltaMode?(s=-t.deltaX*o,-t.deltaY*o):(s=-t.deltaX,-t.deltaY);break;case"wheelDeltaX"in t:s=t.wheelDeltaX/120*o,i=t.wheelDeltaY/120*o;break;case"wheelDelta"in t:s=i=t.wheelDelta/120*o;break;case"detail"in t:s=i=-t.detail/3*o}return s*=e,i*=e,this.scroll.hasVerticalScroll||(Math.abs(i)>Math.abs(s)&&(s=i),i=0),{x:s=this.scroll.hasHorizontalScroll?s:0,y:i,directionX:0<s?-1:s<0?1:0,directionY:0<i?-1:i<0?1:0}},S.prototype.beforeHandler=function(t){var e=this.scroll.options,o=e.preventDefault,s=e.stopPropagation,e=e.preventDefaultException;o&&!ht(t.target,e)&&Q(t),s&&t.stopPropagation()},S.prototype.getEaseTime=function(){var t=this.mouseWheelOpt.easeTime;return t<100&&s("easeTime should be greater than 100.If mouseWheel easeTime is too small,scrollEnd will be triggered many times."),Math.max(t,100)},S.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],t=t[2];e.off(o,t)})},S.pluginName="mouseWheel",S.applyOrder="pre",r=S;function S(t){this.scroll=t,this.wheelEndTimer=0,this.wheelMoveTimer=0,this.wheelStart=!1,this.init()}P.prototype.init=function(){this.handleMutationObserver(),this.handleHooks()},P.prototype.handleMutationObserver=function(){var e=this;"undefined"!=typeof MutationObserver?(this.observer=new MutationObserver(function(t){e.mutationObserverHandler(t,0)}),this.startObserve(this.observer)):this.checkDOMUpdate()},P.prototype.handleHooks=function(){var t=this;this.hooksFn=[],this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,function(){t.stopObserve(),t.handleMutationObserver()}),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.enable,function(){t.stopObserver&&t.handleMutationObserver()}),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.disable,function(){t.stopObserve()}),this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.destroy,function(){t.destroy()})},P.prototype.mutationObserverHandler=function(t,e){var o=this;if(!this.shouldNotRefresh()){for(var s=!1,i=!1,r=0;r<t.length;r++){var n=t[r];if("attributes"!==n.type){s=!0;break}if(n.target!==this.scroll.scroller.content){i=!0;break}}s?this.scroll.refresh():i&&(clearTimeout(e),window.setTimeout(function(){o.shouldNotRefresh()||o.scroll.refresh()},60))}},P.prototype.startObserve=function(t){t.observe(this.scroll.scroller.content,{attributes:!0,childList:!0,subtree:!0})},P.prototype.shouldNotRefresh=function(){var t=this.scroll.scroller,e=t.scrollBehaviorX,o=t.scrollBehaviorY,e=e.currentPos>e.minScrollPos||e.currentPos<e.maxScrollPos||o.currentPos>o.minScrollPos||o.currentPos<o.maxScrollPos;return t.animater.pending||e},P.prototype.checkDOMUpdate=function(){var o=this,s=this.scroll.scroller.content,i=nt(s),r=i.width,n=i.height,h=function(){setTimeout(function(){var t,e;o.stopObserver||(t=(i=nt(s)).width,e=i.height,r===t&&n===e||o.scroll.refresh(),r=t,n=e,h())},1e3)};h()},P.prototype.registerHooks=function(t,e,o){t.on(e,o,this),this.hooksFn.push([t,e,o])},P.prototype.stopObserve=function(){this.stopObserver=!0,this.observer&&this.observer.disconnect()},P.prototype.destroy=function(){this.stopObserve(),this.hooksFn.forEach(function(t){var e=t[0],o=t[1],t=t[2];e.off(o,t)}),this.hooksFn.length=0},P.pluginName="observeDOM";o=P;function P(t){this.scroll=t,this.stopObserver=!1,this.init()}var _t=[{key:"finishPullDown",name:"finishPullDown"},{key:"openPullDown",name:"openPullDown"},{key:"closePullDown",name:"closePullDown"},{key:"autoPullDownRefresh",name:"autoPullDownRefresh"}].map(function(t){return{key:t.key,sourceKey:"plugins.pullDownRefresh."+t.name}}),Vt="pullingDown",Zt="enterThreshold",qt="leaveThreshold",Gt=(b.prototype.setPulling=function(t){this.pulling=t},b.prototype.setThresholdBoundary=function(t){this.thresholdBoundary=t},b.prototype.init=function(){this.handleBScroll(),this.handleOptions(this.scroll.options.pullDownRefresh),this.handleHooks(),this.watch()},b.prototype.handleBScroll=function(){this.scroll.registerType([Vt,Zt,qt]),this.scroll.proxy(_t)},b.prototype.handleOptions=function(t){this.options=n({threshold:90,stop:40},t=!0===(t=void 0===t?{}:t)?{}:t),this.scroll.options.probeType=3},b.prototype.handleHooks=function(){var e=this,t=(this.hooksFn=[],this.scroll.scroller),o=t.scrollBehaviorY;this.currentMinScrollY=this.cachedOriginanMinScrollY=o.minScrollPos,this.registerHooks(this.scroll.hooks,this.scroll.hooks.eventTypes.contentChanged,function(){e.finishPullDown()}),this.registerHooks(o.hooks,o.hooks.eventTypes.computeBoundary,function(t){0<t.maxScrollPos&&(t.maxScrollPos=-1),t.minScrollPos=e.currentMinScrollY}),this.hasMouseWheelPlugin()&&(this.registerHooks(this.scroll,this.scroll.eventTypes.alterOptions,function(t){t.discreteTime=300,t.easeTime=350}),this.registerHooks(this.scroll,this.scroll.eventTypes.mousewheelEnd,function(){t.hooks.trigger(t.hooks.eventTypes.end)}))},b.prototype.registerHooks=function(t,e,o){t.on(e,o,this),this.hooksFn.push([t,e,o])},b.prototype.hasMouseWheelPlugin=function(){return!!this.scroll.eventTypes.alterOptions},b.prototype.watch=function(){var t=this.scroll.scroller;this.watching=!0,this.registerHooks(t.hooks,t.hooks.eventTypes.end,this.checkPullDown),this.registerHooks(this.scroll,this.scroll.eventTypes.scrollStart,this.resetStateBeforeScrollStart),this.registerHooks(this.scroll,this.scroll.eventTypes.scroll,this.checkLocationOfThresholdBoundary),this.hasMouseWheelPlugin()&&this.registerHooks(this.scroll,this.scroll.eventTypes.mousewheelStart,this.resetStateBeforeScrollStart)},b.prototype.resetStateBeforeScrollStart=function(){this.isFetchingStatus()||(this.setPulling(1),this.setThresholdBoundary(0))},b.prototype.checkLocationOfThresholdBoundary=function(){var t,e,o;1===this.pulling&&(t=this.scroll,e=1!==this.thresholdBoundary&&this.locateInsideThresholdBoundary(),o=2!==this.thresholdBoundary&&!this.locateInsideThresholdBoundary(),e&&(this.setThresholdBoundary(1),t.trigger(Zt)),o&&(this.setThresholdBoundary(2),t.trigger(qt)))},b.prototype.locateInsideThresholdBoundary=function(){return this.scroll.y<=this.options.threshold},b.prototype.unwatch=function(){var t=this.scroll,e=t.scroller;this.watching=!1,e.hooks.off(e.hooks.eventTypes.end,this.checkPullDown),t.off(t.eventTypes.scrollStart,this.resetStateBeforeScrollStart),t.off(t.eventTypes.scroll,this.checkLocationOfThresholdBoundary),this.hasMouseWheelPlugin()&&t.off(t.eventTypes.mousewheelStart,this.resetStateBeforeScrollStart)},b.prototype.checkPullDown=function(){var t=this.options,e=t.threshold,t=t.stop;return!(this.scroll.y<e)&&(1===this.pulling&&(this.modifyBehaviorYBoundary(t),this.setPulling(2),this.scroll.trigger(Vt)),this.scroll.scrollTo(this.scroll.x,t,this.scroll.options.bounceTime,f.bounce),this.isFetchingStatus())},b.prototype.isFetchingStatus=func