New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/interaction

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/interaction - npm Package Compare versions

Comparing version 5.1.2 to 5.1.3

6

dist/interaction.min.js
/*!
* @pixi/interaction - v5.1.2
* Compiled Sat, 24 Aug 2019 01:06:18 UTC
* @pixi/interaction - v5.1.3
* Compiled Mon, 09 Sep 2019 04:51:53 UTC
*

@@ -8,3 +8,3 @@ * @pixi/interaction is licensed under the MIT License.

*/
this.PIXI=this.PIXI||{},this.PIXI.interaction=this.PIXI.interaction||{};var _pixi_interaction=function(t,e,i,n,o){"use strict";var r=function(){this.global=new e.Point,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0},s={pointerId:{configurable:!0}};s.pointerId.get=function(){return this.identifier},r.prototype.getLocalPosition=function(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)},r.prototype.copyEvent=function(t){t.isPrimary&&(this.isPrimary=!0),this.button=t.button,this.buttons=Number.isInteger(t.buttons)?t.buttons:t.which,this.width=t.width,this.height=t.height,this.tiltX=t.tiltX,this.tiltY=t.tiltY,this.pointerType=t.pointerType,this.pressure=t.pressure,this.rotationAngle=t.rotationAngle,this.twist=t.twist||0,this.tangentialPressure=t.tangentialPressure||0},r.prototype.reset=function(){this.isPrimary=!1},Object.defineProperties(r.prototype,s);var a=function(){this.stopped=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null};a.prototype.stopPropagation=function(){this.stopped=!0},a.prototype.reset=function(){this.stopped=!1,this.currentTarget=null,this.target=null};var h=function t(e){this._pointerId=e,this._flags=t.FLAGS.NONE},c={pointerId:{configurable:!0},flags:{configurable:!0},none:{configurable:!0},over:{configurable:!0},rightDown:{configurable:!0},leftDown:{configurable:!0}};h.prototype._doSet=function(t,e){this._flags=e?this._flags|t:this._flags&~t},c.pointerId.get=function(){return this._pointerId},c.flags.get=function(){return this._flags},c.flags.set=function(t){this._flags=t},c.none.get=function(){return this._flags===this.constructor.FLAGS.NONE},c.over.get=function(){return 0!=(this._flags&this.constructor.FLAGS.OVER)},c.over.set=function(t){this._doSet(this.constructor.FLAGS.OVER,t)},c.rightDown.get=function(){return 0!=(this._flags&this.constructor.FLAGS.RIGHT_DOWN)},c.rightDown.set=function(t){this._doSet(this.constructor.FLAGS.RIGHT_DOWN,t)},c.leftDown.get=function(){return 0!=(this._flags&this.constructor.FLAGS.LEFT_DOWN)},c.leftDown.set=function(t){this._doSet(this.constructor.FLAGS.LEFT_DOWN,t)},Object.defineProperties(h.prototype,c),h.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4});var p={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return"pointer"===this.cursor},set buttonMode(t){t?this.cursor="pointer":"pointer"===this.cursor&&(this.cursor=null)},cursor:null,get trackedPointers(){return void 0===this._trackedPointers&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};n.DisplayObject.mixin(p);var u=1,l={target:null,data:{global:null}},v=function(t){function n(i,n){t.call(this),n=n||{},this.renderer=i,this.autoPreventDefault=void 0===n.autoPreventDefault||n.autoPreventDefault,this.interactionFrequency=n.interactionFrequency||10,this.mouse=new r,this.mouse.identifier=u,this.mouse.global.set(-999999),this.activeInteractionData={},this.activeInteractionData[u]=this.mouse,this.interactionDataPool=[],this.eventData=new a,this.interactionDOMElement=null,this.moveWhenInside=!1,this.eventsAdded=!1,this.mouseOverRenderer=!1,this.supportsTouchEvents="ontouchstart"in window,this.supportsPointerEvents=!!window.PointerEvent,this.onPointerUp=this.onPointerUp.bind(this),this.processPointerUp=this.processPointerUp.bind(this),this.onPointerCancel=this.onPointerCancel.bind(this),this.processPointerCancel=this.processPointerCancel.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.processPointerDown=this.processPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.processPointerMove=this.processPointerMove.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.processPointerOverOut=this.processPointerOverOut.bind(this),this.onPointerOver=this.onPointerOver.bind(this),this.cursorStyles={default:"inherit",pointer:"pointer"},this.currentCursorMode=null,this.cursor=null,this._tempPoint=new e.Point,this.resolution=1,this.delayedEvents=[],this.setTargetElement(this.renderer.view,this.renderer.resolution)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.hitTest=function(t,e){return l.target=null,l.data.global=t,e||(e=this.renderer._lastObjectRendered),this.processInteractive(l,e,null,!0),l.target},n.prototype.setTargetElement=function(t,e){void 0===e&&(e=1),this.removeEvents(),this.interactionDOMElement=t,this.resolution=e,this.addEvents()},n.prototype.addEvents=function(){this.interactionDOMElement&&(i.Ticker.system.add(this.update,this,i.UPDATE_PRIORITY.INTERACTION),window.navigator.msPointerEnabled?(this.interactionDOMElement.style["-ms-content-zooming"]="none",this.interactionDOMElement.style["-ms-touch-action"]="none"):this.supportsPointerEvents&&(this.interactionDOMElement.style["touch-action"]="none"),this.supportsPointerEvents?(window.document.addEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,!0),window.addEventListener("pointercancel",this.onPointerCancel,!0),window.addEventListener("pointerup",this.onPointerUp,!0)):(window.document.addEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,!0),window.addEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,!0)),this.eventsAdded=!0)},n.prototype.removeEvents=function(){this.interactionDOMElement&&(i.Ticker.system.remove(this.update,this),window.navigator.msPointerEnabled?(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]=""):this.supportsPointerEvents&&(this.interactionDOMElement.style["touch-action"]=""),this.supportsPointerEvents?(window.document.removeEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,!0),window.removeEventListener("pointercancel",this.onPointerCancel,!0),window.removeEventListener("pointerup",this.onPointerUp,!0)):(window.document.removeEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,!0),window.removeEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,!0)),this.interactionDOMElement=null,this.eventsAdded=!1)},n.prototype.update=function(t){if(this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.interactionDOMElement))if(this.didMove)this.didMove=!1;else{for(var e in this.cursor=null,this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(e)){var i=this.activeInteractionData[e];if(i.originalEvent&&"touch"!==i.pointerType){var n=this.configureInteractionEventForDOMEvent(this.eventData,i.originalEvent,i);this.processInteractive(n,this.renderer._lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},n.prototype.setCursorMode=function(t){if(t=t||"default",this.currentCursorMode!==t){this.currentCursorMode=t;var e=this.cursorStyles[t];if(e)switch(typeof e){case"string":this.interactionDOMElement.style.cursor=e;break;case"function":e(t);break;case"object":Object.assign(this.interactionDOMElement.style,e)}else"string"!=typeof t||Object.prototype.hasOwnProperty.call(this.cursorStyles,t)||(this.interactionDOMElement.style.cursor=t)}},n.prototype.dispatchEvent=function(t,e,i){i.stopped||(i.currentTarget=t,i.type=e,t.emit(e,i),t[e]&&t[e](i))},n.prototype.delayDispatchEvent=function(t,e,i){this.delayedEvents.push({displayObject:t,eventString:e,eventData:i})},n.prototype.mapPositionToPoint=function(t,e,i){var n;n=this.interactionDOMElement.parentElement?this.interactionDOMElement.getBoundingClientRect():{x:0,y:0,width:0,height:0};var o=1/this.resolution;t.x=(e-n.left)*(this.interactionDOMElement.width/n.width)*o,t.y=(i-n.top)*(this.interactionDOMElement.height/n.height)*o},n.prototype.processInteractive=function(t,e,i,n,o,r){if(!e||!e.visible)return!1;var s=t.data.global,a=!1,h=o=e.interactive||o,c=!0;if(e.hitArea?(n&&(e.worldTransform.applyInverse(s,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?a=!0:(n=!1,c=!1)),h=!1):e._mask&&n&&(e._mask.containsPoint&&e._mask.containsPoint(s)||(n=!1)),c&&e.interactiveChildren&&e.children)for(var p=e.children,u=p.length-1;u>=0;u--){var l=p[u],v=this.processInteractive(t,l,i,n,h,!0);if(v){if(!l.parent)continue;h=!1,v&&(t.target&&(n=!1),a=!0)}}o&&(n&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(s)&&(a=!0),e.interactive&&(a&&!t.target&&(t.target=e),i&&i(t,e,!!a)));var d=this.delayedEvents;if(d.length&&!r){var m=d.length;this.delayedEvents=[];for(var P=0;P<m;P++){var E=d[P];this.dispatchEvent(E.displayObject,E.eventString,E.eventData)}}return a},n.prototype.onPointerDown=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t);if(this.autoPreventDefault&&e[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(var i=e.length,n=0;n<i;n++){var o=e[n],r=this.getInteractionDataForPointerId(o),s=this.configureInteractionEventForDOMEvent(this.eventData,o,r);if(s.data.originalEvent=t,this.processInteractive(s,this.renderer._lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",s),"touch"===o.pointerType)this.emit("touchstart",s);else if("mouse"===o.pointerType||"pen"===o.pointerType){var a=2===o.button;this.emit(a?"rightdown":"mousedown",this.eventData)}}}},n.prototype.processPointerDown=function(t,e,i){var n=t.data,o=t.data.identifier;if(i)if(e.trackedPointers[o]||(e.trackedPointers[o]=new h(o)),this.dispatchEvent(e,"pointerdown",t),"touch"===n.pointerType)this.dispatchEvent(e,"touchstart",t);else if("mouse"===n.pointerType||"pen"===n.pointerType){var r=2===n.button;r?e.trackedPointers[o].rightDown=!0:e.trackedPointers[o].leftDown=!0,this.dispatchEvent(e,r?"rightdown":"mousedown",t)}},n.prototype.onPointerComplete=function(t,e,i){for(var n=this.normalizeToPointerData(t),o=n.length,r=t.target!==this.interactionDOMElement?"outside":"",s=0;s<o;s++){var a=n[s],h=this.getInteractionDataForPointerId(a),c=this.configureInteractionEventForDOMEvent(this.eventData,a,h);if(c.data.originalEvent=t,this.processInteractive(c,this.renderer._lastObjectRendered,i,e||!r),this.emit(e?"pointercancel":"pointerup"+r,c),"mouse"===a.pointerType||"pen"===a.pointerType){var p=2===a.button;this.emit(p?"rightup"+r:"mouseup"+r,c)}else"touch"===a.pointerType&&(this.emit(e?"touchcancel":"touchend"+r,c),this.releaseInteractionDataForPointerId(a.pointerId,h))}},n.prototype.onPointerCancel=function(t){this.supportsTouchEvents&&"touch"===t.pointerType||this.onPointerComplete(t,!0,this.processPointerCancel)},n.prototype.processPointerCancel=function(t,e){var i=t.data,n=t.data.identifier;void 0!==e.trackedPointers[n]&&(delete e.trackedPointers[n],this.dispatchEvent(e,"pointercancel",t),"touch"===i.pointerType&&this.dispatchEvent(e,"touchcancel",t))},n.prototype.onPointerUp=function(t){this.supportsTouchEvents&&"touch"===t.pointerType||this.onPointerComplete(t,!1,this.processPointerUp)},n.prototype.processPointerUp=function(t,e,i){var n=t.data,o=t.data.identifier,r=e.trackedPointers[o],s="touch"===n.pointerType,a="mouse"===n.pointerType||"pen"===n.pointerType,c=!1;if(a){var p=2===n.button,u=h.FLAGS,l=p?u.RIGHT_DOWN:u.LEFT_DOWN,v=void 0!==r&&r.flags&l;i?(this.dispatchEvent(e,p?"rightup":"mouseup",t),v&&(this.dispatchEvent(e,p?"rightclick":"click",t),c=!0)):v&&this.dispatchEvent(e,p?"rightupoutside":"mouseupoutside",t),r&&(p?r.rightDown=!1:r.leftDown=!1)}i?(this.dispatchEvent(e,"pointerup",t),s&&this.dispatchEvent(e,"touchend",t),r&&(a&&!c||this.dispatchEvent(e,"pointertap",t),s&&(this.dispatchEvent(e,"tap",t),r.over=!1))):r&&(this.dispatchEvent(e,"pointerupoutside",t),s&&this.dispatchEvent(e,"touchendoutside",t)),r&&r.none&&delete e.trackedPointers[o]},n.prototype.onPointerMove=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t);"mouse"!==e[0].pointerType&&"pen"!==e[0].pointerType||(this.didMove=!0,this.cursor=null);for(var i=e.length,n=0;n<i;n++){var o=e[n],r=this.getInteractionDataForPointerId(o),s=this.configureInteractionEventForDOMEvent(this.eventData,o,r);s.data.originalEvent=t,this.processInteractive(s,this.renderer._lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",s),"touch"===o.pointerType&&this.emit("touchmove",s),"mouse"!==o.pointerType&&"pen"!==o.pointerType||this.emit("mousemove",s)}"mouse"===e[0].pointerType&&this.setCursorMode(this.cursor)}},n.prototype.processPointerMove=function(t,e,i){var n=t.data,o="touch"===n.pointerType,r="mouse"===n.pointerType||"pen"===n.pointerType;r&&this.processPointerOverOut(t,e,i),this.moveWhenInside&&!i||(this.dispatchEvent(e,"pointermove",t),o&&this.dispatchEvent(e,"touchmove",t),r&&this.dispatchEvent(e,"mousemove",t))},n.prototype.onPointerOut=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t)[0];"mouse"===e.pointerType&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var i=this.getInteractionDataForPointerId(e),n=this.configureInteractionEventForDOMEvent(this.eventData,e,i);n.data.originalEvent=e,this.processInteractive(n,this.renderer._lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",n),"mouse"===e.pointerType||"pen"===e.pointerType?this.emit("mouseout",n):this.releaseInteractionDataForPointerId(i.identifier)}},n.prototype.processPointerOverOut=function(t,e,i){var n=t.data,o=t.data.identifier,r="mouse"===n.pointerType||"pen"===n.pointerType,s=e.trackedPointers[o];i&&!s&&(s=e.trackedPointers[o]=new h(o)),void 0!==s&&(i&&this.mouseOverRenderer?(s.over||(s.over=!0,this.delayDispatchEvent(e,"pointerover",t),r&&this.delayDispatchEvent(e,"mouseover",t)),r&&null===this.cursor&&(this.cursor=e.cursor)):s.over&&(s.over=!1,this.dispatchEvent(e,"pointerout",this.eventData),r&&this.dispatchEvent(e,"mouseout",t),s.none&&delete e.trackedPointers[o]))},n.prototype.onPointerOver=function(t){var e=this.normalizeToPointerData(t)[0],i=this.getInteractionDataForPointerId(e),n=this.configureInteractionEventForDOMEvent(this.eventData,e,i);n.data.originalEvent=e,"mouse"===e.pointerType&&(this.mouseOverRenderer=!0),this.emit("pointerover",n),"mouse"!==e.pointerType&&"pen"!==e.pointerType||this.emit("mouseover",n)},n.prototype.getInteractionDataForPointerId=function(t){var e,i=t.pointerId;return i===u||"mouse"===t.pointerType?e=this.mouse:this.activeInteractionData[i]?e=this.activeInteractionData[i]:((e=this.interactionDataPool.pop()||new r).identifier=i,this.activeInteractionData[i]=e),e.copyEvent(t),e},n.prototype.releaseInteractionDataForPointerId=function(t){var e=this.activeInteractionData[t];e&&(delete this.activeInteractionData[t],e.reset(),this.interactionDataPool.push(e))},n.prototype.configureInteractionEventForDOMEvent=function(t,e,i){return t.data=i,this.mapPositionToPoint(i.global,e.clientX,e.clientY),"touch"===e.pointerType&&(e.globalX=i.global.x,e.globalY=i.global.y),i.originalEvent=e,t.reset(),t},n.prototype.normalizeToPointerData=function(t){var e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(var i=0,n=t.changedTouches.length;i<n;i++){var o=t.changedTouches[i];void 0===o.button&&(o.button=t.touches.length?1:0),void 0===o.buttons&&(o.buttons=t.touches.length?1:0),void 0===o.isPrimary&&(o.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===o.width&&(o.width=o.radiusX||1),void 0===o.height&&(o.height=o.radiusY||1),void 0===o.tiltX&&(o.tiltX=0),void 0===o.tiltY&&(o.tiltY=0),void 0===o.pointerType&&(o.pointerType="touch"),void 0===o.pointerId&&(o.pointerId=o.identifier||0),void 0===o.pressure&&(o.pressure=o.force||.5),void 0===o.twist&&(o.twist=0),void 0===o.tangentialPressure&&(o.tangentialPressure=0),void 0===o.layerX&&(o.layerX=o.offsetX=o.clientX),void 0===o.layerY&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,e.push(o)}else!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof window.PointerEvent?e.push(t):(void 0===t.isPrimary&&(t.isPrimary=!0),void 0===t.width&&(t.width=1),void 0===t.height&&(t.height=1),void 0===t.tiltX&&(t.tiltX=0),void 0===t.tiltY&&(t.tiltY=0),void 0===t.pointerType&&(t.pointerType="mouse"),void 0===t.pointerId&&(t.pointerId=u),void 0===t.pressure&&(t.pressure=.5),void 0===t.twist&&(t.twist=0),void 0===t.tangentialPressure&&(t.tangentialPressure=0),t.isNormalized=!0,e.push(t));return e},n.prototype.destroy=function(){this.removeEvents(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this._tempPoint=null},n}(o.EventEmitter);return t.InteractionData=r,t.InteractionEvent=a,t.InteractionManager=v,t.InteractionTrackingData=h,t.interactiveTarget=p,t}({},PIXI,PIXI,PIXI,PIXI.utils);Object.assign(this.PIXI.interaction,_pixi_interaction);
this.PIXI=this.PIXI||{},this.PIXI.interaction=this.PIXI.interaction||{};var _pixi_interaction=function(t,e,i,n,o){"use strict";var r=function(){this.global=new e.Point,this.target=null,this.originalEvent=null,this.identifier=null,this.isPrimary=!1,this.button=0,this.buttons=0,this.width=0,this.height=0,this.tiltX=0,this.tiltY=0,this.pointerType=null,this.pressure=0,this.rotationAngle=0,this.twist=0,this.tangentialPressure=0},s={pointerId:{configurable:!0}};s.pointerId.get=function(){return this.identifier},r.prototype.getLocalPosition=function(t,e,i){return t.worldTransform.applyInverse(i||this.global,e)},r.prototype.copyEvent=function(t){t.isPrimary&&(this.isPrimary=!0),this.button=t.button,this.buttons=Number.isInteger(t.buttons)?t.buttons:t.which,this.width=t.width,this.height=t.height,this.tiltX=t.tiltX,this.tiltY=t.tiltY,this.pointerType=t.pointerType,this.pressure=t.pressure,this.rotationAngle=t.rotationAngle,this.twist=t.twist||0,this.tangentialPressure=t.tangentialPressure||0},r.prototype.reset=function(){this.isPrimary=!1},Object.defineProperties(r.prototype,s);var a=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.target=null,this.currentTarget=null,this.type=null,this.data=null};a.prototype.stopPropagation=function(){this.stopped=!0,this.stopPropagationHint=!0,this.stopsPropagatingAt=this.currentTarget},a.prototype.reset=function(){this.stopped=!1,this.stopsPropagatingAt=null,this.stopPropagationHint=!1,this.currentTarget=null,this.target=null};var h=function t(e){this._pointerId=e,this._flags=t.FLAGS.NONE},c={pointerId:{configurable:!0},flags:{configurable:!0},none:{configurable:!0},over:{configurable:!0},rightDown:{configurable:!0},leftDown:{configurable:!0}};h.prototype._doSet=function(t,e){this._flags=e?this._flags|t:this._flags&~t},c.pointerId.get=function(){return this._pointerId},c.flags.get=function(){return this._flags},c.flags.set=function(t){this._flags=t},c.none.get=function(){return this._flags===this.constructor.FLAGS.NONE},c.over.get=function(){return 0!=(this._flags&this.constructor.FLAGS.OVER)},c.over.set=function(t){this._doSet(this.constructor.FLAGS.OVER,t)},c.rightDown.get=function(){return 0!=(this._flags&this.constructor.FLAGS.RIGHT_DOWN)},c.rightDown.set=function(t){this._doSet(this.constructor.FLAGS.RIGHT_DOWN,t)},c.leftDown.get=function(){return 0!=(this._flags&this.constructor.FLAGS.LEFT_DOWN)},c.leftDown.set=function(t){this._doSet(this.constructor.FLAGS.LEFT_DOWN,t)},Object.defineProperties(h.prototype,c),h.FLAGS=Object.freeze({NONE:0,OVER:1,LEFT_DOWN:2,RIGHT_DOWN:4});var p={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return"pointer"===this.cursor},set buttonMode(t){t?this.cursor="pointer":"pointer"===this.cursor&&(this.cursor=null)},cursor:null,get trackedPointers(){return void 0===this._trackedPointers&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};n.DisplayObject.mixin(p);var u=1,l={target:null,data:{global:null}},v=function(t){function n(i,n){t.call(this),n=n||{},this.renderer=i,this.autoPreventDefault=void 0===n.autoPreventDefault||n.autoPreventDefault,this.interactionFrequency=n.interactionFrequency||10,this.mouse=new r,this.mouse.identifier=u,this.mouse.global.set(-999999),this.activeInteractionData={},this.activeInteractionData[u]=this.mouse,this.interactionDataPool=[],this.eventData=new a,this.interactionDOMElement=null,this.moveWhenInside=!1,this.eventsAdded=!1,this.mouseOverRenderer=!1,this.supportsTouchEvents="ontouchstart"in window,this.supportsPointerEvents=!!window.PointerEvent,this.onPointerUp=this.onPointerUp.bind(this),this.processPointerUp=this.processPointerUp.bind(this),this.onPointerCancel=this.onPointerCancel.bind(this),this.processPointerCancel=this.processPointerCancel.bind(this),this.onPointerDown=this.onPointerDown.bind(this),this.processPointerDown=this.processPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.processPointerMove=this.processPointerMove.bind(this),this.onPointerOut=this.onPointerOut.bind(this),this.processPointerOverOut=this.processPointerOverOut.bind(this),this.onPointerOver=this.onPointerOver.bind(this),this.cursorStyles={default:"inherit",pointer:"pointer"},this.currentCursorMode=null,this.cursor=null,this._tempPoint=new e.Point,this.resolution=1,this.delayedEvents=[],this.setTargetElement(this.renderer.view,this.renderer.resolution)}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n.prototype.hitTest=function(t,e){return l.target=null,l.data.global=t,e||(e=this.renderer._lastObjectRendered),this.processInteractive(l,e,null,!0),l.target},n.prototype.setTargetElement=function(t,e){void 0===e&&(e=1),this.removeEvents(),this.interactionDOMElement=t,this.resolution=e,this.addEvents()},n.prototype.addEvents=function(){this.interactionDOMElement&&(i.Ticker.system.add(this.update,this,i.UPDATE_PRIORITY.INTERACTION),window.navigator.msPointerEnabled?(this.interactionDOMElement.style["-ms-content-zooming"]="none",this.interactionDOMElement.style["-ms-touch-action"]="none"):this.supportsPointerEvents&&(this.interactionDOMElement.style["touch-action"]="none"),this.supportsPointerEvents?(window.document.addEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("pointerover",this.onPointerOver,!0),window.addEventListener("pointercancel",this.onPointerCancel,!0),window.addEventListener("pointerup",this.onPointerUp,!0)):(window.document.addEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.addEventListener("mouseover",this.onPointerOver,!0),window.addEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.addEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.addEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.addEventListener("touchmove",this.onPointerMove,!0)),this.eventsAdded=!0)},n.prototype.removeEvents=function(){this.interactionDOMElement&&(i.Ticker.system.remove(this.update,this),window.navigator.msPointerEnabled?(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]=""):this.supportsPointerEvents&&(this.interactionDOMElement.style["touch-action"]=""),this.supportsPointerEvents?(window.document.removeEventListener("pointermove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("pointerdown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("pointerleave",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("pointerover",this.onPointerOver,!0),window.removeEventListener("pointercancel",this.onPointerCancel,!0),window.removeEventListener("pointerup",this.onPointerUp,!0)):(window.document.removeEventListener("mousemove",this.onPointerMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onPointerOut,!0),this.interactionDOMElement.removeEventListener("mouseover",this.onPointerOver,!0),window.removeEventListener("mouseup",this.onPointerUp,!0)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener("touchstart",this.onPointerDown,!0),this.interactionDOMElement.removeEventListener("touchcancel",this.onPointerCancel,!0),this.interactionDOMElement.removeEventListener("touchend",this.onPointerUp,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onPointerMove,!0)),this.interactionDOMElement=null,this.eventsAdded=!1)},n.prototype.update=function(t){if(this._deltaTime+=t,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this.interactionDOMElement))if(this.didMove)this.didMove=!1;else{for(var e in this.cursor=null,this.activeInteractionData)if(this.activeInteractionData.hasOwnProperty(e)){var i=this.activeInteractionData[e];if(i.originalEvent&&"touch"!==i.pointerType){var n=this.configureInteractionEventForDOMEvent(this.eventData,i.originalEvent,i);this.processInteractive(n,this.renderer._lastObjectRendered,this.processPointerOverOut,!0)}}this.setCursorMode(this.cursor)}},n.prototype.setCursorMode=function(t){if(t=t||"default",this.currentCursorMode!==t){this.currentCursorMode=t;var e=this.cursorStyles[t];if(e)switch(typeof e){case"string":this.interactionDOMElement.style.cursor=e;break;case"function":e(t);break;case"object":Object.assign(this.interactionDOMElement.style,e)}else"string"!=typeof t||Object.prototype.hasOwnProperty.call(this.cursorStyles,t)||(this.interactionDOMElement.style.cursor=t)}},n.prototype.dispatchEvent=function(t,e,i){i.stopPropagationHint&&t!==i.stopsPropagatingAt||(i.currentTarget=t,i.type=e,t.emit(e,i),t[e]&&t[e](i))},n.prototype.delayDispatchEvent=function(t,e,i){this.delayedEvents.push({displayObject:t,eventString:e,eventData:i})},n.prototype.mapPositionToPoint=function(t,e,i){var n;n=this.interactionDOMElement.parentElement?this.interactionDOMElement.getBoundingClientRect():{x:0,y:0,width:0,height:0};var o=1/this.resolution;t.x=(e-n.left)*(this.interactionDOMElement.width/n.width)*o,t.y=(i-n.top)*(this.interactionDOMElement.height/n.height)*o},n.prototype.processInteractive=function(t,e,i,n,o,r){if(!e||!e.visible)return!1;var s=t.data.global,a=!1,h=o=e.interactive||o,c=!0;if(e.hitArea?(n&&(e.worldTransform.applyInverse(s,this._tempPoint),e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)?a=!0:(n=!1,c=!1)),h=!1):e._mask&&n&&(e._mask.containsPoint&&e._mask.containsPoint(s)||(n=!1)),c&&e.interactiveChildren&&e.children)for(var p=e.children,u=p.length-1;u>=0;u--){var l=p[u],v=this.processInteractive(t,l,i,n,h,!0);if(v){if(!l.parent)continue;h=!1,v&&(t.target&&(n=!1),a=!0)}}o&&(n&&!t.target&&!e.hitArea&&e.containsPoint&&e.containsPoint(s)&&(a=!0),e.interactive&&(a&&!t.target&&(t.target=e),i&&i(t,e,!!a)));var d=this.delayedEvents;if(d.length&&!r){t.stopPropagationHint=!1;var m=d.length;this.delayedEvents=[];for(var P=0;P<m;P++){var E=d[P],g=E.displayObject,f=E.eventString,y=E.eventData;y.stopsPropagatingAt===g&&(y.stopPropagationHint=!0),this.dispatchEvent(g,f,y)}}return a},n.prototype.onPointerDown=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t);if(this.autoPreventDefault&&e[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(var i=e.length,n=0;n<i;n++){var o=e[n],r=this.getInteractionDataForPointerId(o),s=this.configureInteractionEventForDOMEvent(this.eventData,o,r);if(s.data.originalEvent=t,this.processInteractive(s,this.renderer._lastObjectRendered,this.processPointerDown,!0),this.emit("pointerdown",s),"touch"===o.pointerType)this.emit("touchstart",s);else if("mouse"===o.pointerType||"pen"===o.pointerType){var a=2===o.button;this.emit(a?"rightdown":"mousedown",this.eventData)}}}},n.prototype.processPointerDown=function(t,e,i){var n=t.data,o=t.data.identifier;if(i)if(e.trackedPointers[o]||(e.trackedPointers[o]=new h(o)),this.dispatchEvent(e,"pointerdown",t),"touch"===n.pointerType)this.dispatchEvent(e,"touchstart",t);else if("mouse"===n.pointerType||"pen"===n.pointerType){var r=2===n.button;r?e.trackedPointers[o].rightDown=!0:e.trackedPointers[o].leftDown=!0,this.dispatchEvent(e,r?"rightdown":"mousedown",t)}},n.prototype.onPointerComplete=function(t,e,i){for(var n=this.normalizeToPointerData(t),o=n.length,r=t.target!==this.interactionDOMElement?"outside":"",s=0;s<o;s++){var a=n[s],h=this.getInteractionDataForPointerId(a),c=this.configureInteractionEventForDOMEvent(this.eventData,a,h);if(c.data.originalEvent=t,this.processInteractive(c,this.renderer._lastObjectRendered,i,e||!r),this.emit(e?"pointercancel":"pointerup"+r,c),"mouse"===a.pointerType||"pen"===a.pointerType){var p=2===a.button;this.emit(p?"rightup"+r:"mouseup"+r,c)}else"touch"===a.pointerType&&(this.emit(e?"touchcancel":"touchend"+r,c),this.releaseInteractionDataForPointerId(a.pointerId,h))}},n.prototype.onPointerCancel=function(t){this.supportsTouchEvents&&"touch"===t.pointerType||this.onPointerComplete(t,!0,this.processPointerCancel)},n.prototype.processPointerCancel=function(t,e){var i=t.data,n=t.data.identifier;void 0!==e.trackedPointers[n]&&(delete e.trackedPointers[n],this.dispatchEvent(e,"pointercancel",t),"touch"===i.pointerType&&this.dispatchEvent(e,"touchcancel",t))},n.prototype.onPointerUp=function(t){this.supportsTouchEvents&&"touch"===t.pointerType||this.onPointerComplete(t,!1,this.processPointerUp)},n.prototype.processPointerUp=function(t,e,i){var n=t.data,o=t.data.identifier,r=e.trackedPointers[o],s="touch"===n.pointerType,a="mouse"===n.pointerType||"pen"===n.pointerType,c=!1;if(a){var p=2===n.button,u=h.FLAGS,l=p?u.RIGHT_DOWN:u.LEFT_DOWN,v=void 0!==r&&r.flags&l;i?(this.dispatchEvent(e,p?"rightup":"mouseup",t),v&&(this.dispatchEvent(e,p?"rightclick":"click",t),c=!0)):v&&this.dispatchEvent(e,p?"rightupoutside":"mouseupoutside",t),r&&(p?r.rightDown=!1:r.leftDown=!1)}i?(this.dispatchEvent(e,"pointerup",t),s&&this.dispatchEvent(e,"touchend",t),r&&(a&&!c||this.dispatchEvent(e,"pointertap",t),s&&(this.dispatchEvent(e,"tap",t),r.over=!1))):r&&(this.dispatchEvent(e,"pointerupoutside",t),s&&this.dispatchEvent(e,"touchendoutside",t)),r&&r.none&&delete e.trackedPointers[o]},n.prototype.onPointerMove=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t);"mouse"!==e[0].pointerType&&"pen"!==e[0].pointerType||(this.didMove=!0,this.cursor=null);for(var i=e.length,n=0;n<i;n++){var o=e[n],r=this.getInteractionDataForPointerId(o),s=this.configureInteractionEventForDOMEvent(this.eventData,o,r);s.data.originalEvent=t,this.processInteractive(s,this.renderer._lastObjectRendered,this.processPointerMove,!0),this.emit("pointermove",s),"touch"===o.pointerType&&this.emit("touchmove",s),"mouse"!==o.pointerType&&"pen"!==o.pointerType||this.emit("mousemove",s)}"mouse"===e[0].pointerType&&this.setCursorMode(this.cursor)}},n.prototype.processPointerMove=function(t,e,i){var n=t.data,o="touch"===n.pointerType,r="mouse"===n.pointerType||"pen"===n.pointerType;r&&this.processPointerOverOut(t,e,i),this.moveWhenInside&&!i||(this.dispatchEvent(e,"pointermove",t),o&&this.dispatchEvent(e,"touchmove",t),r&&this.dispatchEvent(e,"mousemove",t))},n.prototype.onPointerOut=function(t){if(!this.supportsTouchEvents||"touch"!==t.pointerType){var e=this.normalizeToPointerData(t)[0];"mouse"===e.pointerType&&(this.mouseOverRenderer=!1,this.setCursorMode(null));var i=this.getInteractionDataForPointerId(e),n=this.configureInteractionEventForDOMEvent(this.eventData,e,i);n.data.originalEvent=e,this.processInteractive(n,this.renderer._lastObjectRendered,this.processPointerOverOut,!1),this.emit("pointerout",n),"mouse"===e.pointerType||"pen"===e.pointerType?this.emit("mouseout",n):this.releaseInteractionDataForPointerId(i.identifier)}},n.prototype.processPointerOverOut=function(t,e,i){var n=t.data,o=t.data.identifier,r="mouse"===n.pointerType||"pen"===n.pointerType,s=e.trackedPointers[o];i&&!s&&(s=e.trackedPointers[o]=new h(o)),void 0!==s&&(i&&this.mouseOverRenderer?(s.over||(s.over=!0,this.delayDispatchEvent(e,"pointerover",t),r&&this.delayDispatchEvent(e,"mouseover",t)),r&&null===this.cursor&&(this.cursor=e.cursor)):s.over&&(s.over=!1,this.dispatchEvent(e,"pointerout",this.eventData),r&&this.dispatchEvent(e,"mouseout",t),s.none&&delete e.trackedPointers[o]))},n.prototype.onPointerOver=function(t){var e=this.normalizeToPointerData(t)[0],i=this.getInteractionDataForPointerId(e),n=this.configureInteractionEventForDOMEvent(this.eventData,e,i);n.data.originalEvent=e,"mouse"===e.pointerType&&(this.mouseOverRenderer=!0),this.emit("pointerover",n),"mouse"!==e.pointerType&&"pen"!==e.pointerType||this.emit("mouseover",n)},n.prototype.getInteractionDataForPointerId=function(t){var e,i=t.pointerId;return i===u||"mouse"===t.pointerType?e=this.mouse:this.activeInteractionData[i]?e=this.activeInteractionData[i]:((e=this.interactionDataPool.pop()||new r).identifier=i,this.activeInteractionData[i]=e),e.copyEvent(t),e},n.prototype.releaseInteractionDataForPointerId=function(t){var e=this.activeInteractionData[t];e&&(delete this.activeInteractionData[t],e.reset(),this.interactionDataPool.push(e))},n.prototype.configureInteractionEventForDOMEvent=function(t,e,i){return t.data=i,this.mapPositionToPoint(i.global,e.clientX,e.clientY),"touch"===e.pointerType&&(e.globalX=i.global.x,e.globalY=i.global.y),i.originalEvent=e,t.reset(),t},n.prototype.normalizeToPointerData=function(t){var e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(var i=0,n=t.changedTouches.length;i<n;i++){var o=t.changedTouches[i];void 0===o.button&&(o.button=t.touches.length?1:0),void 0===o.buttons&&(o.buttons=t.touches.length?1:0),void 0===o.isPrimary&&(o.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===o.width&&(o.width=o.radiusX||1),void 0===o.height&&(o.height=o.radiusY||1),void 0===o.tiltX&&(o.tiltX=0),void 0===o.tiltY&&(o.tiltY=0),void 0===o.pointerType&&(o.pointerType="touch"),void 0===o.pointerId&&(o.pointerId=o.identifier||0),void 0===o.pressure&&(o.pressure=o.force||.5),void 0===o.twist&&(o.twist=0),void 0===o.tangentialPressure&&(o.tangentialPressure=0),void 0===o.layerX&&(o.layerX=o.offsetX=o.clientX),void 0===o.layerY&&(o.layerY=o.offsetY=o.clientY),o.isNormalized=!0,e.push(o)}else!(t instanceof MouseEvent)||this.supportsPointerEvents&&t instanceof window.PointerEvent?e.push(t):(void 0===t.isPrimary&&(t.isPrimary=!0),void 0===t.width&&(t.width=1),void 0===t.height&&(t.height=1),void 0===t.tiltX&&(t.tiltX=0),void 0===t.tiltY&&(t.tiltY=0),void 0===t.pointerType&&(t.pointerType="mouse"),void 0===t.pointerId&&(t.pointerId=u),void 0===t.pressure&&(t.pressure=.5),void 0===t.twist&&(t.twist=0),void 0===t.tangentialPressure&&(t.tangentialPressure=0),t.isNormalized=!0,e.push(t));return e},n.prototype.destroy=function(){this.removeEvents(),this.removeAllListeners(),this.renderer=null,this.mouse=null,this.eventData=null,this.interactionDOMElement=null,this.onPointerDown=null,this.processPointerDown=null,this.onPointerUp=null,this.processPointerUp=null,this.onPointerCancel=null,this.processPointerCancel=null,this.onPointerMove=null,this.processPointerMove=null,this.onPointerOut=null,this.processPointerOverOut=null,this.onPointerOver=null,this._tempPoint=null},n}(o.EventEmitter);return t.InteractionData=r,t.InteractionEvent=a,t.InteractionManager=v,t.InteractionTrackingData=h,t.interactiveTarget=p,t}({},PIXI,PIXI,PIXI,PIXI.utils);Object.assign(this.PIXI.interaction,_pixi_interaction);
//# sourceMappingURL=interaction.min.js.map
{
"name": "@pixi/interaction",
"version": "5.1.2",
"version": "5.1.3",
"main": "lib/interaction.js",

@@ -28,17 +28,17 @@ "module": "lib/interaction.es.js",

"dependencies": {
"@pixi/core": "^5.1.2",
"@pixi/display": "^5.1.2",
"@pixi/core": "^5.1.3",
"@pixi/display": "^5.1.3",
"@pixi/math": "^5.1.0",
"@pixi/ticker": "^5.1.1",
"@pixi/utils": "^5.1.2"
"@pixi/ticker": "^5.1.3",
"@pixi/utils": "^5.1.3"
},
"devDependencies": {
"@pixi/canvas-display": "^5.1.2",
"@pixi/canvas-graphics": "^5.1.2",
"@pixi/canvas-renderer": "^5.1.2",
"@pixi/canvas-sprite": "^5.1.2",
"@pixi/graphics": "^5.1.2",
"@pixi/sprite": "^5.1.2"
"@pixi/canvas-display": "^5.1.3",
"@pixi/canvas-graphics": "^5.1.3",
"@pixi/canvas-renderer": "^5.1.3",
"@pixi/canvas-sprite": "^5.1.3",
"@pixi/graphics": "^5.1.3",
"@pixi/sprite": "^5.1.3"
},
"gitHead": "9d8381bfb348e8ba570e1cab26bf2f699446f0ca"
"gitHead": "ee5ed4ddb3e1967f7e8a88c952479d51368fd3e2"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc