phaser3-rex-plugins
Version:
2 lines (1 loc) • 26.8 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).rexscrollerplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(s=i.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(s,"string"))?r:String(r)),i);}var s,r;}function i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var n,i=r(t);if(e){var s=r(this).constructor;n=Reflect.construct(i,arguments,s);}else n=i.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return a(t)}(this,n)}}function h(){return h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(i){var s=Object.getOwnPropertyDescriptor(i,e);return s.get?s.get.call(arguments.length<3?t:n):s.value}},h.apply(this,arguments)}var l={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},c=Phaser.Scene,v=function(t){return t instanceof c},f=Phaser.Game,p=function(t){return t instanceof f},d=function(e){return null==e||"object"!==t(e)?null:p(e)?e:p(e.game)?e.game:v(e)?e.sys.game:v(e.scene)?e.scene.sys.game:void 0},y=Phaser.Utils.Objects.GetValue,m=function(){function n(t,i){e(this,n),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(y(i,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this));}return i(n,[{key:"shutdown",value:function(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0);}},{key:"destroy",value:function(t){this.shutdown(t);}},{key:"onEnvDestroy",value:function(){this.destroy(!0);}},{key:"onParentDestroy",value:function(t,e){this.destroy(e);}},{key:"setParent",value:function(e){var n;return this.parent=e,this.scene=null==(n=e)||"object"!==t(n)?null:v(n)?n:n.scene&&v(n.scene)?n.scene:n.parent&&n.parent.scene&&v(n.parent.scene)?n.parent.scene:null,this.game=d(e),this}}]),n}();function _(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(m.prototype,l);var g={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function i(){}function s(t,e,n){this.fn=t,this.context=e,this.once=n||!1;}function r(t,e,i,r,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new s(i,r||t,o),u=n?n+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e];}function a(){this._events=new i,this._eventsCount=0;}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,s=[];if(0===this._eventsCount)return s;for(i in t=this._events)e.call(t,i)&&s.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return [];if(i.fn)return [i.fn];for(var s=0,r=i.length,o=new Array(r);s<r;s++)o[s]=i[s].fn;return o},a.prototype.listenerCount=function(t){var e=n?n+t:t,i=this._events[e];return i?i.fn?1:i.length:0},a.prototype.emit=function(t,e,i,s,r,o){var a=n?n+t:t;if(!this._events[a])return !1;var u,h,l=this._events[a],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,i),!0;case 4:return l.fn.call(l.context,e,i,s),!0;case 5:return l.fn.call(l.context,e,i,s,r),!0;case 6:return l.fn.call(l.context,e,i,s,r,o),!0}for(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];l.fn.apply(l.context,u);}else {var v,f=l.length;for(h=0;h<f;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),c){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,i);break;case 4:l[h].fn.call(l[h].context,e,i,s);break;default:if(!u)for(v=1,u=new Array(c-1);v<c;v++)u[v-1]=arguments[v];l[h].fn.apply(l[h].context,u);}}return !0},a.prototype.on=function(t,e,n){return r(this,t,e,n,!1)},a.prototype.once=function(t,e,n){return r(this,t,e,n,!0)},a.prototype.removeListener=function(t,e,i,s){var r=n?n+t:t;if(!this._events[r])return this;if(!e)return o(this,r),this;var a=this._events[r];if(a.fn)a.fn!==e||s&&!a.once||i&&a.context!==i||o(this,r);else {for(var u=0,h=[],l=a.length;u<l;u++)(a[u].fn!==e||s&&!a[u].once||i&&a[u].context!==i)&&h.push(a[u]);h.length?this._events[r]=1===h.length?h[0]:h:o(this,r);}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&o(this,e)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a;}(g);var E=function(t){s(r,t);var n=u(r);function r(){return e(this,r),n.apply(this,arguments)}return i(r,[{key:"shutdown",value:function(){this.removeAllListeners();}},{key:"destroy",value:function(){this.removeAllListeners();}}]),r}(_(g.exports)),k={setEventEmitter:function(t,e){return void 0===e&&(e=E),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},b=function(t,e,n){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var i=e.split("."),s=t,r=n,o=0;o<i.length;o++){if(!s.hasOwnProperty(i[o])){r=n;break}r=s[i[o]],s=s[i[o]];}return r}return n}return n},w=["next","exit","enter"],S=function(){function t(n){e(this,t);var i=b(n,"states",void 0);i&&this.addStates(i);var s=b(n,"extend",void 0);if(s)for(var r in s)this.hasOwnProperty(r)&&void 0!==this[r]||(this[r]=s[r]);var o=b(n,"eventEmitter",void 0),a=b(n,"EventEmitterClass",void 0);this.setEventEmitter(o,a),this._stateLock=!1,this.resetFromJSON(n);}return i(t,[{key:"shutdown",value:function(){this.destroyEventEmitter();}},{key:"destroy",value:function(){this.shutdown();}},{key:"resetFromJSON",value:function(t){this.setEnable(b(t,"enable",!0)),this.start(b(t,"start",void 0));var e=b(t,"init",void 0);return e&&e.call(this),this}},{key:"toJSON",value:function(){return {curState:this.state,prevState:this.prevState,enable:this.enable,start:this._start}}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),this.enable=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}},{key:"state",get:function(){return this._state},set:function(t){if(this.enable&&!this._stateLock&&this._state!==t){if(this._prevState=this._state,this._state=t,this._stateLock=!0,this.emit("statechange",this),null!=this._prevState){var e="exit_"+this._prevState,n=this[e];n&&n.call(this),this.emit(e,this);}if(this._stateLock=!1,null!=this._state){var i="enter_"+this._state,s=this[i];s&&s.call(this),this.emit(i,this);}}}},{key:"prevState",get:function(){return this._prevState}},{key:"start",value:function(t){return this._start=t,this._prevState=void 0,this._state=t,this}},{key:"goto",value:function(t){return null!=t&&(this.state=t),this}},{key:"next",value:function(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}},{key:"stateProperties",get:function(){return w}},{key:"addState",value:function(t,e){"string"!=typeof t&&(t=(e=t).name);for(var n=this.stateProperties,i=0,s=n.length;i<s;i++){var r=n[i],o=e[r];o&&(this["".concat(r,"_").concat(t)]=o);}return this}},{key:"addStates",value:function(t){if(Array.isArray(t))for(var e=0,n=t.length;e<n;e++)this.addState(t[e]);else for(var i in t)this.addState(i,t[i]);return this}},{key:"runMethod",value:function(t,e,n,i,s,r){var o=this[t+"_"+this.state];if(o){var a=arguments.length;switch(a){case 1:return o.call(this);case 2:return o.call(this,e);case 3:return o.call(this,e,n);case 4:return o.call(this,e,n,i);case 5:return o.call(this,e,n,i,s);case 6:return o.call(this,e,n,i,s,r)}for(var u=new Array(a-1),h=1;h<a;h++)u[h-1]=arguments[h];return o.apply(this,u)}}}]),t}();Object.assign(S.prototype,k);var x=function(t,e,n,i,s){void 0===s&&(s=!1);var r=t._events[e];if(!r)return !1;for(var o=0,a=r.length;o<a;o++){var u=r[o];if(u.fn===n&&u.context===i&&u.once===s)return !0}return !1},D=["next","exit","enter","update","preupdate","postupdate"],O=function(t){s(o,t);var n=u(o);function o(){return e(this,o),n.apply(this,arguments)}return i(o,[{key:"shutdown",value:function(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,h(r(o.prototype),"shutdown",this).call(this);}},{key:"resetFromJSON",value:function(t){return h(r(o.prototype),"resetFromJSON",this).call(this,t),this._scene=b(t,"scene",void 0),this}},{key:"stateProperties",get:function(){return D}},{key:"update",value:function(t,e){this.runMethod("update",t,e);}},{key:"preupdate",value:function(t,e){this.runMethod("preupdate",t,e);}},{key:"postupdate",value:function(t,e){this.runMethod("postupdate",t,e);}},{key:"startUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return x(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}},{key:"stopUpdate",value:function(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}},{key:"startPreUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return x(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}},{key:"stopPreUpdate",value:function(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}},{key:"startPostUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return x(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}},{key:"stopPostUpdate",value:function(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}]),o}(S),P=function(t){s(r,t);var n=u(r);function r(t,i){var s;return e(this,r),(s=n.call(this,i)).parent=t,s.init(),s}return i(r,[{key:"init",value:function(){this.start("IDLE");}},{key:"next_IDLE",value:function(){var t,e=this.parent;return e.dragState.isDown&&(t=0===e.dragThreshold?"DRAG":"DRAGBEGIN"),t}},{key:"update_IDLE",value:function(t,e){this.next();}},{key:"next_DRAGBEGIN",value:function(){var t=this.parent,e=t.dragState;return e.isDown?e.pointer.getDistance()>=t.dragThreshold?"DRAG":"DRAGBEGIN":"IDLE"}},{key:"update_DRAGBEGIN",value:function(t,e){this.next();}},{key:"next_DRAG",value:function(){var t,e=this.parent;return e.dragState.isUp&&(t=e.outOfBounds?"BACK":e.slidingEnable?"SLIDE":"IDLE"),t}},{key:"update_DRAG",value:function(t,e){var n=this.parent;n.dragState.justMoved&&n.dragging(),this.next();}},{key:"enter_DRAG",value:function(){this.parent.onDragStart();}},{key:"exit_DRAG",value:function(){this.parent.onDragEnd();}},{key:"next_SLIDE",value:function(){var t,e=this.parent;return e.dragState.isDown?t="DRAG":e.isSliding||(t="IDLE"),t}},{key:"enter_SLIDE",value:function(){this.parent.onSliding();}},{key:"exit_SLIDE",value:function(){this.parent.stop();}},{key:"update_SLIDE",value:function(t,e){this.parent.sliding(t,e),this.next();}},{key:"next_BACK",value:function(){var t,e=this.parent;return e.dragState.isDown?t="DRAG":e.isPullBack||(t="IDLE"),t}},{key:"enter_BACK",value:function(){this.parent.onPullBack();}},{key:"exit_BACK",value:function(){this.parent.stop();}},{key:"update_BACK",value:function(t,e){this.parent.pullBack(t,e),this.next();}}]),r}(O),M=Phaser.Utils.Objects.GetValue,A=Phaser.Math.Distance.Between,L=function(t){s(o,t);var n=u(o);function o(t,i){var s;return e(this,o),(s=n.call(this,t,i))._enable=void 0,t.setInteractive(M(i,"inputConfig",void 0)),s.resetFromJSON(i),s.boot(),s}return i(o,[{key:"resetFromJSON",value:function(t){return this.pointer=void 0,this.isInTouched=!1,this.holdStartTime=void 0,this.x=void 0,this.y=void 0,this.preX=void 0,this.preY=void 0,this.localX=void 0,this.localY=void 0,this.justMoved=!1,this.setEnable(M(t,"enable",!0)),this.holdThreshold=M(t,"holdThreshold",50),this.pointerOutReleaseEnable=M(t,"pointerOutRelease",!0),this}},{key:"boot",value:function(){this.parent.on("pointerdown",this.onPointIn,this),this.parent.on("pointerup",this.onPointOut,this),this.pointerOutReleaseEnable&&this.parent.on("pointerout",this.onPointOut,this),this.parent.on("pointermove",this.onPointerMove,this),this.scene.sys.events.on("preupdate",this.preupdate,this);}},{key:"shutdown",value:function(t){this.isShutdown||(this.scene.sys.events.off("preupdate",this.preupdate,this),this.pointer=void 0,h(r(o.prototype),"shutdown",this).call(this,t));}},{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(t||(this.isInTouched=!1,this.pointer=void 0),this._enable=t);}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),this.enable=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}},{key:"setPointerOutReleaseEnable",value:function(t){return void 0===t&&(t=!0),this.pointerOutReleaseEnable=t,this}},{key:"isDown",get:function(){return this.pointer&&this.pointer.isDown}},{key:"isUp",get:function(){return !this.isDown}},{key:"dx",get:function(){return this.x-this.preX}},{key:"dy",get:function(){return this.y-this.preY}},{key:"dt",get:function(){var t;return t=this.scene,d(t).loop.delta}},{key:"speed",get:function(){return this.x===this.preX&&this.y===this.preY?0:A(this.preX,this.preY,this.x,this.y)/(.001*this.dt)}},{key:"speedX",get:function(){return this.dx/(.001*this.dt)}},{key:"speedY",get:function(){return this.dy/(.001*this.dt)}},{key:"onPointIn",value:function(t,e,n){this.enable&&t.isDown&&void 0===this.pointer&&(this.pointer=t,this.localX=e,this.localY=n);}},{key:"onPointOut",value:function(t){this.enable&&this.pointer===t&&(this.pointer=void 0);}},{key:"onPointerMove",value:function(t,e,n){this.enable&&t.isDown&&this.pointer===t&&(this.localX=e,this.localY=n);}},{key:"preupdate",value:function(t,e){if(this.enable){var n=this.pointer;this.justMoved=!1,n&&!this.isInTouched?(this.x=n.worldX,this.y=n.worldY,this.preX=n.worldX,this.preY=n.worldY,this.isInTouched=!0,this.holdStartTime=void 0,this.emit("touchstart",n,this.localX,this.localY)):n&&this.isInTouched?this.x===n.x&&this.y===n.y?void 0===this.holdStartTime?this.holdStartTime=t:t-this.holdStartTime>this.holdThreshold&&(this.preX=this.x,this.preY=this.y):(this.preX=this.x,this.preY=this.y,this.x=n.worldX,this.y=n.worldY,this.holdStartTime=void 0,this.justMoved=!0,this.emit("touchmove",n,this.localX,this.localY)):!n&&this.isInTouched&&(this.isInTouched=!1,this.holdStartTime=void 0,this.emit("touchend",n));}}}]),o}(m),R=Phaser.Utils.Objects.GetValue,j=function(){function t(n){e(this,t),this.resetFromJSON(n);}return i(t,[{key:"resetFromJSON",value:function(t){return this.setValue(R(t,"value",0)),this.setSpeed(R(t,"speed",0)),this.setAcceleration(R(t,"acceleration",0)),this}},{key:"reset",value:function(){this.setValue(0),this.setSpeed(0),this.setAcceleration(0);}},{key:"setValue",value:function(t){return this.value=t,this}},{key:"setSpeed",value:function(t){return this.speed=t,this}},{key:"setAcceleration",value:function(t){return this.acceleration=t,this}},{key:"updateSpeed",value:function(t){return 0!==this.acceleration&&(this.speed+=this.acceleration*t,this.speed<0&&(this.speed=0)),this}},{key:"getDeltaValue",value:function(t){return this.updateSpeed(t),this.speed<=0?0:this.speed*t}},{key:"update",value:function(t){return this.updateSpeed(t),this.speed>0&&(this.value+=this.getDeltaValue(t)),this}},{key:"isMoving",get:function(){return this.speed>0}}]),t}(),B=function(){function t(){e(this,t),this.value,this.dir,this.movement=new j;}return i(t,[{key:"init",value:function(t,e,n,i,s){return this.value=t,this.end=s,this.dir=void 0!==s?t<s:e,this.movement.setSpeed(n).setAcceleration(-i),this}},{key:"stop",value:function(){this.movement.reset();}},{key:"update",value:function(t){var e=this.movement.getDeltaValue(t);return this.dir||(e=-e),void 0===this.end?this.value+=e:0===e?this.value=this.end:(this.value+=e,this.dir?this.value>this.end&&(this.value=this.end):this.value<this.end&&(this.value=this.end)),this}},{key:"isMoving",get:function(){return this.movement.isMoving}}]),t}(),T=Phaser.Utils.Objects.GetValue,V=Phaser.Math.Clamp,C=function(t){s(o,t);var n=u(o);function o(t,i){var s;e(this,o),s=n.call(this,t,i);var r=T(i,"enable",!0);s._state=new P(a(s),{enable:r,eventEmitter:!1});var u={inputConfig:T(i,"inputConfig",void 0),enable:r,pointerOutRelease:T(i,"pointerOutRelease",!0),eventEmitter:!1};s.dragState=new L(t,u),s._enable=void 0,s._value=void 0,s._slowDown=new B;var h=T(i,"valuechangeCallback",null);if(null!==h){var l=T(i,"valuechangeCallbackScope",void 0);s.on("valuechange",h,l);}if(null!==(h=T(i,"overmaxCallback",null))){l=T(i,"overmaxCallbackScope",void 0);s.on("overmax",h,l);}if(null!==(h=T(i,"overminCallback",null))){l=T(i,"overminCallbackScope",void 0);s.on("overmin",h,l);}return s.resetFromJSON(i),s.boot(),s}return i(o,[{key:"resetFromJSON",value:function(t){this.setOrientationMode(T(t,"orientation",0)),this.setDragThreshold(T(t,"threshold",10)),this.setSlidingDeceleration(T(t,"slidingDeceleration",5e3)),this.setBackDeceleration(T(t,"backDeceleration",2e3));var e=T(t,"dragRate",1);e*=T(t,"dragReverse",!1)?-1:1,this.setDragRate(e);var n=T(t,"bounds",void 0);return n?this.setBounds(n):this.setBounds(T(t,"max",0),T(t,"min",0)),this.setValue(T(t,"value",this.maxValue||0)),this.setEnable(T(t,"enable",!0)),this}},{key:"boot",value:function(){this.scene.sys.events.on("preupdate",this._state.update,this._state);}},{key:"shutdown",value:function(t){this.isShutdown||(this.scene.sys.events.off("preupdate",this._state.update,this._state),this._state.destroy(t),this.dragState.destroy(t),this._state=void 0,this.dragState=void 0,h(r(o.prototype),"shutdown",this).call(this,t));}},{key:"enable",get:function(){return this._enable},set:function(t){if(this._enable!==t)return this._enable=t,this._state.setEnable(t),this.dragState.setEnable(t),this}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),this.enable=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}},{key:"setOrientationMode",value:function(t){return "string"==typeof t&&(t=I[t]),this.orientationMode=t,this}},{key:"setDragThreshold",value:function(t){return this.dragThreshold=t,this}},{key:"setSlidingDeceleration",value:function(t){return this.slidingDeceleration=t,this}},{key:"setBackDeceleration",value:function(t){return this.backDeceleration=t,this}},{key:"setDragRate",value:function(t){return this.dragRate=t,this}},{key:"setBounds",value:function(t,e){if(Array.isArray(t)){var n=t;t=n[0],e=n[1];}return t<e?(this.minValue=t,this.maxValue=e):(this.minValue=e,this.maxValue=t),this}},{key:"value",get:function(){return this._value},set:function(t){if(t!==this._value){var e=this._value,n=this.overMax(t),i=this.overMin(t);n&&this.emit("overmax",t,e),i&&this.emit("overmin",t,e),this.backEnable||(n&&(t=this.maxValue),i&&(t=this.minValue)),this._value=t,this.emit("valuechange",t,e);}}},{key:"setValue",value:function(t,e){return void 0===e&&(e=!1),e&&(t=V(t,this.minValue,this.maxValue)),this.value=t,this}},{key:"addValue",value:function(t,e){return this.setValue(this.value+t,e),this}},{key:"state",get:function(){return this._state.state}},{key:"isDragging",get:function(){return this.dragState.isInTouched}},{key:"outOfMaxBound",get:function(){return this.overMax(this.value)}},{key:"outOfMinBound",get:function(){return this.overMin(this.value)}},{key:"outOfBounds",get:function(){return this.outOfMinBound||this.outOfMaxBound}},{key:"overMax",value:function(t){return null!=this.maxValue&&t>this.maxValue}},{key:"overMin",value:function(t){return null!=this.minValue&&t<this.minValue}},{key:"backEnable",get:function(){return "number"==typeof this.backDeceleration}},{key:"isPullBack",get:function(){return this._slowDown.isMoving}},{key:"slidingEnable",get:function(){return "number"==typeof this.slidingDeceleration}},{key:"isSliding",get:function(){return this._slowDown.isMoving}},{key:"dragDelta",get:function(){var t;return t=0===this.orientationMode?this.dragState.dy:1===this.orientationMode?this.dragState.dx:0,t*=this.dragRate}},{key:"dragSpeed",get:function(){var t;return t=0===this.orientationMode?this.dragState.speedY:1===this.orientationMode?this.dragState.speedX:0,t*=this.dragRate}},{key:"onDragStart",value:function(){this.emit("dragstart");}},{key:"onDragEnd",value:function(){this.emit("dragend");}},{key:"dragging",value:function(){this.value+=this.dragDelta;}},{key:"onSliding",value:function(){var t=this.value,e=this.dragSpeed;if(0===e)return this._slowDown.stop(),void this._state.next();var n=this.slidingDeceleration;this._slowDown.init(t,e>0,Math.abs(e),n);}},{key:"sliding",value:function(t,e){e*=.001;var n=this._slowDown.update(e).value;this.overMax(n)?(this.value=this.maxValue,this._slowDown.stop()):this.overMin(n)?(this.value=this.minValue,this._slowDown.stop()):this.value=n;}},{key:"onPullBack",value:function(){var t=this.value,e=this.outOfMinBound?this.minValue:this.maxValue,n=Math.abs(e-t),i=this.backDeceleration,s=Math.sqrt(2*i*n);this._slowDown.init(t,void 0,s,i,e);}},{key:"pullBack",value:function(t,e){e*=.001,this.value=this._slowDown.update(e).value,this._slowDown.isMoving||this._state.next();}},{key:"stop",value:function(){this._slowDown.stop();}}]),o}(m),I={y:0,v:0,vertical:0,x:1,h:1,horizontal:1};return function(t){s(r,Phaser.Plugins.BasePlugin);var n=u(r);function r(t){return e(this,r),n.call(this,t)}return i(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"add",value:function(t,e){return new C(t,e)}}]),r}()}));