{"ast":null,"code":"import _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nimport { State } from \"../../State\";\nimport { PointerType } from \"../interfaces\";\nimport PointerTracker from \"./PointerTracker\";\nimport { isPointerInBounds } from \"../utils\";\nvar GestureHandlerOrchestrator = function () {\n function GestureHandlerOrchestrator() {\n _classCallCheck(this, GestureHandlerOrchestrator);\n _defineProperty(this, \"gestureHandlers\", []);\n _defineProperty(this, \"awaitingHandlers\", []);\n _defineProperty(this, \"handlersToCancel\", []);\n _defineProperty(this, \"handlingChangeSemaphore\", 0);\n _defineProperty(this, \"activationIndex\", 0);\n }\n _createClass(GestureHandlerOrchestrator, [{\n key: \"scheduleFinishedHandlersCleanup\",\n value: function scheduleFinishedHandlersCleanup() {\n if (this.handlingChangeSemaphore === 0) {\n this.cleanupFinishedHandlers();\n }\n }\n }, {\n key: \"cleanHandler\",\n value: function cleanHandler(handler) {\n handler.reset();\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_VALUE);\n }\n }, {\n key: \"removeHandlerFromOrchestrator\",\n value: function removeHandlerFromOrchestrator(handler) {\n this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);\n this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);\n this.handlersToCancel.splice(this.handlersToCancel.indexOf(handler), 1);\n }\n }, {\n key: \"cleanupFinishedHandlers\",\n value: function cleanupFinishedHandlers() {\n for (var i = this.gestureHandlers.length - 1; i >= 0; --i) {\n var handler = this.gestureHandlers[i];\n if (!handler) {\n continue;\n }\n if (this.isFinished(handler.getState()) && !handler.isAwaiting()) {\n this.gestureHandlers.splice(i, 1);\n this.cleanHandler(handler);\n }\n }\n }\n }, {\n key: \"hasOtherHandlerToWaitFor\",\n value: function hasOtherHandlerToWaitFor(handler) {\n var _this = this;\n var hasToWait = false;\n this.gestureHandlers.forEach(function (otherHandler) {\n if (otherHandler && !_this.isFinished(otherHandler.getState()) && _this.shouldHandlerWaitForOther(handler, otherHandler)) {\n hasToWait = true;\n return;\n }\n });\n return hasToWait;\n }\n }, {\n key: \"tryActivate\",\n value: function tryActivate(handler) {\n if (this.hasOtherHandlerToWaitFor(handler)) {\n this.addAwaitingHandler(handler);\n } else if (handler.getState() !== State.CANCELLED && handler.getState() !== State.FAILED) {\n if (this.shouldActivate(handler)) {\n this.makeActive(handler);\n } else {\n switch (handler.getState()) {\n case State.ACTIVE:\n handler.fail();\n break;\n case State.BEGAN:\n handler.cancel();\n }\n }\n }\n }\n }, {\n key: \"shouldActivate\",\n value: function shouldActivate(handler) {\n for (var otherHandler of this.gestureHandlers) {\n if (this.shouldHandlerBeCancelledBy(handler, otherHandler)) {\n return false;\n }\n }\n return true;\n }\n }, {\n key: \"cleanupAwaitingHandlers\",\n value: function cleanupAwaitingHandlers(handler) {\n for (var i = 0; i < this.awaitingHandlers.length; ++i) {\n if (!this.awaitingHandlers[i].isAwaiting() && this.shouldHandlerWaitForOther(this.awaitingHandlers[i], handler)) {\n this.cleanHandler(this.awaitingHandlers[i]);\n this.awaitingHandlers.splice(i, 1);\n }\n }\n }\n }, {\n key: \"onHandlerStateChange\",\n value: function onHandlerStateChange(handler, newState, oldState, sendIfDisabled) {\n var _this2 = this;\n if (!handler.isEnabled() && !sendIfDisabled) {\n return;\n }\n this.handlingChangeSemaphore += 1;\n if (this.isFinished(newState)) {\n this.awaitingHandlers.forEach(function (otherHandler) {\n if (_this2.shouldHandlerWaitForOther(otherHandler, handler)) {\n if (newState === State.END) {\n otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.cancel();\n if (otherHandler.getState() === State.END) {\n otherHandler.sendEvent(State.CANCELLED, State.BEGAN);\n }\n otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.setAwaiting(false);\n } else {\n _this2.tryActivate(otherHandler);\n }\n }\n });\n }\n if (newState === State.ACTIVE) {\n this.tryActivate(handler);\n } else if (oldState === State.ACTIVE || oldState === State.END) {\n if (handler.isActive()) {\n handler.sendEvent(newState, oldState);\n } else if (oldState === State.ACTIVE && (newState === State.CANCELLED || newState === State.FAILED)) {\n handler.sendEvent(newState, State.BEGAN);\n }\n } else if (oldState !== State.UNDETERMINED || newState !== State.CANCELLED) {\n handler.sendEvent(newState, oldState);\n }\n this.handlingChangeSemaphore -= 1;\n this.scheduleFinishedHandlersCleanup();\n if (this.awaitingHandlers.indexOf(handler) < 0) {\n this.cleanupAwaitingHandlers(handler);\n }\n }\n }, {\n key: \"makeActive\",\n value: function makeActive(handler) {\n var _this3 = this;\n var currentState = handler.getState();\n handler.setActive(true);\n handler.setShouldResetProgress(true);\n handler.setActivationIndex(this.activationIndex++);\n this.gestureHandlers.forEach(function (otherHandler) {\n if (_this3.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n _this3.handlersToCancel.push(otherHandler);\n }\n });\n for (var i = this.handlersToCancel.length - 1; i >= 0; --i) {\n var _this$handlersToCance;\n (_this$handlersToCance = this.handlersToCancel[i]) === null || _this$handlersToCance === void 0 ? void 0 : _this$handlersToCance.cancel();\n }\n this.awaitingHandlers.forEach(function (otherHandler) {\n if (_this3.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.cancel();\n otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.setAwaiting(true);\n }\n });\n handler.sendEvent(State.ACTIVE, State.BEGAN);\n if (currentState !== State.ACTIVE) {\n handler.sendEvent(State.END, State.ACTIVE);\n if (currentState !== State.END) {\n handler.sendEvent(State.UNDETERMINED, State.END);\n }\n }\n if (handler.isAwaiting()) {\n handler.setAwaiting(false);\n for (var _i = 0; _i < this.awaitingHandlers.length; ++_i) {\n if (this.awaitingHandlers[_i] === handler) {\n this.awaitingHandlers.splice(_i, 1);\n }\n }\n }\n this.handlersToCancel = [];\n }\n }, {\n key: \"addAwaitingHandler\",\n value: function addAwaitingHandler(handler) {\n var alreadyExists = false;\n this.awaitingHandlers.forEach(function (otherHandler) {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n if (alreadyExists) {\n return;\n }\n this.awaitingHandlers.push(handler);\n handler.setAwaiting(true);\n handler.setActivationIndex(this.activationIndex++);\n }\n }, {\n key: \"recordHandlerIfNotPresent\",\n value: function recordHandlerIfNotPresent(handler) {\n var alreadyExists = false;\n this.gestureHandlers.forEach(function (otherHandler) {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n if (alreadyExists) {\n return;\n }\n this.gestureHandlers.push(handler);\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_SAFE_INTEGER);\n }\n }, {\n key: \"shouldHandlerWaitForOther\",\n value: function shouldHandlerWaitForOther(handler, otherHandler) {\n return handler !== otherHandler && (handler.shouldWaitForHandlerFailure(otherHandler) || otherHandler.shouldRequireToWaitForFailure(handler));\n }\n }, {\n key: \"canRunSimultaneously\",\n value: function canRunSimultaneously(gh1, gh2) {\n return gh1 === gh2 || gh1.shouldRecognizeSimultaneously(gh2) || gh2.shouldRecognizeSimultaneously(gh1);\n }\n }, {\n key: \"shouldHandlerBeCancelledBy\",\n value: function shouldHandlerBeCancelledBy(handler, otherHandler) {\n if (this.canRunSimultaneously(handler, otherHandler)) {\n return false;\n }\n if (handler !== otherHandler && (handler.isAwaiting() || handler.getState() === State.ACTIVE)) {\n return handler.shouldBeCancelledByOther(otherHandler);\n }\n var handlerPointers = handler.getTrackedPointersID();\n var otherPointers = otherHandler.getTrackedPointersID();\n if (!PointerTracker.shareCommonPointers(handlerPointers, otherPointers) && handler.getView() !== otherHandler.getView()) {\n return this.checkOverlap(handler, otherHandler);\n }\n return true;\n }\n }, {\n key: \"checkOverlap\",\n value: function checkOverlap(handler, otherHandler) {\n var handlerPointers = handler.getTrackedPointersID();\n var otherPointers = otherHandler.getTrackedPointersID();\n var overlap = false;\n handlerPointers.forEach(function (pointer) {\n var handlerX = handler.getTracker().getLastX(pointer);\n var handlerY = handler.getTracker().getLastY(pointer);\n if (isPointerInBounds(handler.getView(), {\n x: handlerX,\n y: handlerY\n }) && isPointerInBounds(otherHandler.getView(), {\n x: handlerX,\n y: handlerY\n })) {\n overlap = true;\n }\n });\n otherPointers.forEach(function (pointer) {\n var otherX = otherHandler.getTracker().getLastX(pointer);\n var otherY = otherHandler.getTracker().getLastY(pointer);\n if (isPointerInBounds(handler.getView(), {\n x: otherX,\n y: otherY\n }) && isPointerInBounds(otherHandler.getView(), {\n x: otherX,\n y: otherY\n })) {\n overlap = true;\n }\n });\n return overlap;\n }\n }, {\n key: \"isFinished\",\n value: function isFinished(state) {\n return state === State.END || state === State.FAILED || state === State.CANCELLED;\n }\n }, {\n key: \"cancelMouseAndPenGestures\",\n value: function cancelMouseAndPenGestures(currentHandler) {\n this.gestureHandlers.forEach(function (handler) {\n if (handler.getPointerType() !== PointerType.MOUSE && handler.getPointerType() !== PointerType.PEN) {\n return;\n }\n if (handler !== currentHandler) {\n handler.cancel();\n } else {\n handler.getTracker().resetTracker();\n }\n });\n }\n }], [{\n key: \"getInstance\",\n value: function getInstance() {\n if (!GestureHandlerOrchestrator.instance) {\n GestureHandlerOrchestrator.instance = new GestureHandlerOrchestrator();\n }\n return GestureHandlerOrchestrator.instance;\n }\n }]);\n return GestureHandlerOrchestrator;\n}();\nexport { GestureHandlerOrchestrator as default };\n_defineProperty(GestureHandlerOrchestrator, \"instance\", void 0);","map":{"version":3,"sources":["GestureHandlerOrchestrator.ts"],"names":["State","PointerType","PointerTracker","isPointerInBounds","GestureHandlerOrchestrator","constructor","scheduleFinishedHandlersCleanup","handlingChangeSemaphore","cleanupFinishedHandlers","cleanHandler","handler","reset","setActive","setAwaiting","setActivationIndex","Number","MAX_VALUE","removeHandlerFromOrchestrator","gestureHandlers","splice","indexOf","awaitingHandlers","handlersToCancel","i","length","isFinished","getState","isAwaiting","hasOtherHandlerToWaitFor","hasToWait","forEach","otherHandler","shouldHandlerWaitForOther","tryActivate","addAwaitingHandler","CANCELLED","FAILED","shouldActivate","makeActive","ACTIVE","fail","BEGAN","cancel","shouldHandlerBeCancelledBy","cleanupAwaitingHandlers","onHandlerStateChange","newState","oldState","sendIfDisabled","isEnabled","END","sendEvent","isActive","UNDETERMINED","currentState","setShouldResetProgress","activationIndex","push","alreadyExists","recordHandlerIfNotPresent","MAX_SAFE_INTEGER","shouldWaitForHandlerFailure","shouldRequireToWaitForFailure","canRunSimultaneously","gh1","gh2","shouldRecognizeSimultaneously","shouldBeCancelledByOther","handlerPointers","getTrackedPointersID","otherPointers","shareCommonPointers","getView","checkOverlap","overlap","pointer","handlerX","getTracker","getLastX","handlerY","getLastY","x","y","otherX","otherY","state","cancelMouseAndPenGestures","currentHandler","getPointerType","MOUSE","PEN","resetTracker","getInstance","instance"],"mappings":";;;;;;;;;;;;;;;AAAA,SAASA,KAAT;AACA,SAASC,WAAT;AAGA,OAAOC,cAAP;AACA,SAASC,iBAAT;AAAA,IAEqBC,0BAAN;EAYLC,sCAAc;IAAA;IAAA,eAAA,CAAA,IAAA,EAAA,iBAAA,EATsB,EAStB,CAAA;IAAA,eAAA,CAAA,IAAA,EAAA,kBAAA,EARuB,EAQvB,CAAA;IAAA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAPuB,EAOvB,CAAA;IAAA,eAAA,CAAA,IAAA,EAAA,yBAAA,EALY,CAKZ,CAAA;IAAA,eAAA,CAAA,IAAA,EAAA,iBAAA,EAJI,CAIJ,CAAA;EAAE;EAAA;IAAA;IAAA,OAEhBC,2CAAwC;MAC9C,IAAI,IAAA,CAAKC,uBAAL,KAAiC,CAArC,EAAwC;QACtC,IAAA,CAAKC,uBAAL,EAAA;MACD;IACF;EAAA;IAAA;IAAA,OAEOC,sBAAaC,OAAD,EAAgC;MAClDA,OAAO,CAACC,KAARD,EAAAA;M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EAAAA,KAA6BT,WAAW,CAACyF,GAF3C,EAGE;UACA;QACD;QAED,IAAIhF,OAAO,KAAK6E,cAAhB,EAAgC;UAC9B7E,OAAO,CAACgC,MAARhC,EAAAA;QACD,CAFD,MAEO;UAQLA,OAAO,CAACmE,UAARnE,EAAAA,CAAqBiF,YAArBjF,EAAAA;QACD;MACF,CApBD,CAAA;IAqBD;EAAA;IAAA;IAAA,OAEakF,uBAA0C;MACtD,IAAI,CAACxF,0BAA0B,CAACyF,QAAhC,EAA0C;QACxCzF,0BAA0B,CAACyF,QAA3BzF,GAAsC,IAAIA,0BAAJ,EAAtCA;MACD;MAED,OAAOA,0BAA0B,CAACyF,QAAlC;IACD;EAAA;EAAA;AAAA;AAAA,SApYkBzF,0BAAN;gBAAMA,0B","sourcesContent":["import { State } from '../../State';\nimport { PointerType } from '../interfaces';\n\nimport GestureHandler from '../handlers/GestureHandler';\nimport PointerTracker from './PointerTracker';\nimport { isPointerInBounds } from '../utils';\n\nexport default class GestureHandlerOrchestrator {\n private static instance: GestureHandlerOrchestrator;\n\n private gestureHandlers: GestureHandler[] = [];\n private awaitingHandlers: GestureHandler[] = [];\n private handlersToCancel: GestureHandler[] = [];\n\n private handlingChangeSemaphore = 0;\n private activationIndex = 0;\n\n // Private beacuse of Singleton\n // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function\n private constructor() {}\n\n private scheduleFinishedHandlersCleanup(): void {\n if (this.handlingChangeSemaphore === 0) {\n this.cleanupFinishedHandlers();\n }\n }\n\n private cleanHandler(handler: GestureHandler): void {\n handler.reset();\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_VALUE);\n }\n\n public removeHandlerFromOrchestrator(handler: GestureHandler): void {\n this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);\n this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);\n this.handlersToCancel.splice(this.handlersToCancel.indexOf(handler), 1);\n }\n\n private cleanupFinishedHandlers(): void {\n for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {\n const handler = this.gestureHandlers[i];\n\n if (!handler) {\n continue;\n }\n if (this.isFinished(handler.getState()) && !handler.isAwaiting()) {\n this.gestureHandlers.splice(i, 1);\n\n this.cleanHandler(handler);\n }\n }\n }\n\n private hasOtherHandlerToWaitFor(handler: GestureHandler): boolean {\n let hasToWait = false;\n this.gestureHandlers.forEach((otherHandler) => {\n if (\n otherHandler &&\n !this.isFinished(otherHandler.getState()) &&\n this.shouldHandlerWaitForOther(handler, otherHandler)\n ) {\n hasToWait = true;\n return;\n }\n });\n\n return hasToWait;\n }\n\n private tryActivate(handler: GestureHandler): void {\n if (this.hasOtherHandlerToWaitFor(handler)) {\n this.addAwaitingHandler(handler);\n } else if (\n handler.getState() !== State.CANCELLED &&\n handler.getState() !== State.FAILED\n ) {\n if (this.shouldActivate(handler)) {\n this.makeActive(handler);\n } else {\n switch (handler.getState()) {\n case State.ACTIVE:\n handler.fail();\n break;\n case State.BEGAN:\n handler.cancel();\n }\n }\n }\n }\n\n private shouldActivate(handler: GestureHandler): boolean {\n for (const otherHandler of this.gestureHandlers) {\n if (this.shouldHandlerBeCancelledBy(handler, otherHandler)) {\n return false;\n }\n }\n\n return true;\n }\n\n private cleanupAwaitingHandlers(handler: GestureHandler): void {\n for (let i = 0; i < this.awaitingHandlers.length; ++i) {\n if (\n !this.awaitingHandlers[i].isAwaiting() &&\n this.shouldHandlerWaitForOther(this.awaitingHandlers[i], handler)\n ) {\n this.cleanHandler(this.awaitingHandlers[i]);\n this.awaitingHandlers.splice(i, 1);\n }\n }\n }\n\n public onHandlerStateChange(\n handler: GestureHandler,\n newState: State,\n oldState: State,\n sendIfDisabled?: boolean\n ): void {\n if (!handler.isEnabled() && !sendIfDisabled) {\n return;\n }\n\n this.handlingChangeSemaphore += 1;\n\n if (this.isFinished(newState)) {\n this.awaitingHandlers.forEach((otherHandler) => {\n if (this.shouldHandlerWaitForOther(otherHandler, handler)) {\n if (newState === State.END) {\n otherHandler?.cancel();\n if (otherHandler.getState() === State.END) {\n // Handle edge case, where discrete gestures end immediately after activation thus\n // their state is set to END and when the gesture they are waiting for activates they\n // should be cancelled, however `cancel` was never sent as gestures were already in the END state.\n // Send synthetic BEGAN -> CANCELLED to properly handle JS logic\n otherHandler.sendEvent(State.CANCELLED, State.BEGAN);\n }\n otherHandler?.setAwaiting(false);\n } else {\n this.tryActivate(otherHandler);\n }\n }\n });\n }\n\n if (newState === State.ACTIVE) {\n this.tryActivate(handler);\n } else if (oldState === State.ACTIVE || oldState === State.END) {\n if (handler.isActive()) {\n handler.sendEvent(newState, oldState);\n } else if (\n oldState === State.ACTIVE &&\n (newState === State.CANCELLED || newState === State.FAILED)\n ) {\n handler.sendEvent(newState, State.BEGAN);\n }\n } else if (\n oldState !== State.UNDETERMINED ||\n newState !== State.CANCELLED\n ) {\n handler.sendEvent(newState, oldState);\n }\n\n this.handlingChangeSemaphore -= 1;\n\n this.scheduleFinishedHandlersCleanup();\n\n if (this.awaitingHandlers.indexOf(handler) < 0) {\n this.cleanupAwaitingHandlers(handler);\n }\n }\n\n private makeActive(handler: GestureHandler): void {\n const currentState = handler.getState();\n\n handler.setActive(true);\n handler.setShouldResetProgress(true);\n handler.setActivationIndex(this.activationIndex++);\n\n this.gestureHandlers.forEach((otherHandler) => {\n // Order of arguments is correct - we check whether current handler should cancel existing handlers\n\n if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n this.handlersToCancel.push(otherHandler);\n }\n });\n\n for (let i = this.handlersToCancel.length - 1; i >= 0; --i) {\n this.handlersToCancel[i]?.cancel();\n }\n this.awaitingHandlers.forEach((otherHandler) => {\n if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n otherHandler?.cancel();\n otherHandler?.setAwaiting(true);\n }\n });\n\n handler.sendEvent(State.ACTIVE, State.BEGAN);\n\n if (currentState !== State.ACTIVE) {\n handler.sendEvent(State.END, State.ACTIVE);\n if (currentState !== State.END) {\n handler.sendEvent(State.UNDETERMINED, State.END);\n }\n }\n\n if (handler.isAwaiting()) {\n handler.setAwaiting(false);\n for (let i = 0; i < this.awaitingHandlers.length; ++i) {\n if (this.awaitingHandlers[i] === handler) {\n this.awaitingHandlers.splice(i, 1);\n }\n }\n }\n\n this.handlersToCancel = [];\n }\n\n private addAwaitingHandler(handler: GestureHandler): void {\n let alreadyExists = false;\n\n this.awaitingHandlers.forEach((otherHandler) => {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n\n if (alreadyExists) {\n return;\n }\n\n this.awaitingHandlers.push(handler);\n\n handler.setAwaiting(true);\n handler.setActivationIndex(this.activationIndex++);\n }\n\n public recordHandlerIfNotPresent(handler: GestureHandler): void {\n let alreadyExists = false;\n\n this.gestureHandlers.forEach((otherHandler) => {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n\n if (alreadyExists) {\n return;\n }\n\n this.gestureHandlers.push(handler);\n\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_SAFE_INTEGER);\n }\n\n private shouldHandlerWaitForOther(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n return (\n handler !== otherHandler &&\n (handler.shouldWaitForHandlerFailure(otherHandler) ||\n otherHandler.shouldRequireToWaitForFailure(handler))\n );\n }\n\n private canRunSimultaneously(\n gh1: GestureHandler,\n gh2: GestureHandler\n ): boolean {\n return (\n gh1 === gh2 ||\n gh1.shouldRecognizeSimultaneously(gh2) ||\n gh2.shouldRecognizeSimultaneously(gh1)\n );\n }\n\n private shouldHandlerBeCancelledBy(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n if (this.canRunSimultaneously(handler, otherHandler)) {\n return false;\n }\n\n if (\n handler !== otherHandler &&\n (handler.isAwaiting() || handler.getState() === State.ACTIVE)\n ) {\n // For now it always returns false\n return handler.shouldBeCancelledByOther(otherHandler);\n }\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n if (\n !PointerTracker.shareCommonPointers(handlerPointers, otherPointers) &&\n handler.getView() !== otherHandler.getView()\n ) {\n return this.checkOverlap(handler, otherHandler);\n }\n\n return true;\n }\n\n private checkOverlap(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n // If handlers don't have common pointers, default return value is false.\n // However, if at least on pointer overlaps with both handlers, we return true\n // This solves issue in overlapping parents example\n\n // TODO: Find better way to handle that issue, for example by activation order and handler cancelling\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n let overlap = false;\n\n handlerPointers.forEach((pointer: number) => {\n const handlerX: number = handler.getTracker().getLastX(pointer);\n const handlerY: number = handler.getTracker().getLastY(pointer);\n\n if (\n isPointerInBounds(handler.getView(), { x: handlerX, y: handlerY }) &&\n isPointerInBounds(otherHandler.getView(), { x: handlerX, y: handlerY })\n ) {\n overlap = true;\n }\n });\n\n otherPointers.forEach((pointer: number) => {\n const otherX: number = otherHandler.getTracker().getLastX(pointer);\n const otherY: number = otherHandler.getTracker().getLastY(pointer);\n\n if (\n isPointerInBounds(handler.getView(), { x: otherX, y: otherY }) &&\n isPointerInBounds(otherHandler.getView(), { x: otherX, y: otherY })\n ) {\n overlap = true;\n }\n });\n\n return overlap;\n }\n\n private isFinished(state: State): boolean {\n return (\n state === State.END || state === State.FAILED || state === State.CANCELLED\n );\n }\n\n // This function is called when handler receives touchdown event\n // If handler is using mouse or pen as a pointer and any handler receives touch event,\n // mouse/pen event dissappears - it doesn't send onPointerCancel nor onPointerUp (and others)\n // This became a problem because handler was left at active state without any signal to end or fail\n // To handle this, when new touch event is received, we loop through active handlers and check which type of\n // pointer they're using. If there are any handler with mouse/pen as a pointer, we cancel them\n public cancelMouseAndPenGestures(currentHandler: GestureHandler): void {\n this.gestureHandlers.forEach((handler: GestureHandler) => {\n if (\n handler.getPointerType() !== PointerType.MOUSE &&\n handler.getPointerType() !== PointerType.PEN\n ) {\n return;\n }\n\n if (handler !== currentHandler) {\n handler.cancel();\n } else {\n // Handler that received touch event should have its pointer tracker reset\n // This allows handler to smoothly change from mouse/pen to touch\n // The drawback is, that when we try to use mouse/pen one more time, it doesn't send onPointerDown at the first time\n // so it is required to click two times to get handler to work\n //\n // However, handler will receive manually created onPointerEnter that is triggered in EventManager in onPointerMove method.\n // There may be possibility to use that fact to make handler respond properly to first mouse click\n handler.getTracker().resetTracker();\n }\n });\n }\n\n public static getInstance(): GestureHandlerOrchestrator {\n if (!GestureHandlerOrchestrator.instance) {\n GestureHandlerOrchestrator.instance = new GestureHandlerOrchestrator();\n }\n\n return GestureHandlerOrchestrator.instance;\n }\n}\n"]},"metadata":{},"sourceType":"module"}