You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
14 KiB
1 line
14 KiB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport _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 { EventTypes } from \"../interfaces\";\nvar RotationGestureDetector = function () {\n function RotationGestureDetector(callbacks) {\n _classCallCheck(this, RotationGestureDetector);\n _defineProperty(this, \"onRotationBegin\", void 0);\n _defineProperty(this, \"onRotation\", void 0);\n _defineProperty(this, \"onRotationEnd\", void 0);\n _defineProperty(this, \"currentTime\", 0);\n _defineProperty(this, \"previousTime\", 0);\n _defineProperty(this, \"previousAngle\", 0);\n _defineProperty(this, \"rotation\", 0);\n _defineProperty(this, \"anchorX\", 0);\n _defineProperty(this, \"anchorY\", 0);\n _defineProperty(this, \"isInProgress\", false);\n _defineProperty(this, \"keyPointers\", [NaN, NaN]);\n this.onRotationBegin = callbacks.onRotationBegin;\n this.onRotation = callbacks.onRotation;\n this.onRotationEnd = callbacks.onRotationEnd;\n }\n _createClass(RotationGestureDetector, [{\n key: \"updateCurrent\",\n value: function updateCurrent(event, tracker) {\n this.previousTime = this.currentTime;\n this.currentTime = event.time;\n var _this$keyPointers = _slicedToArray(this.keyPointers, 2),\n firstPointerID = _this$keyPointers[0],\n secondPointerID = _this$keyPointers[1];\n var firstPointerX = tracker.getLastX(firstPointerID);\n var firstPointerY = tracker.getLastY(firstPointerID);\n var secondPointerX = tracker.getLastX(secondPointerID);\n var secondPointerY = tracker.getLastY(secondPointerID);\n var vectorX = secondPointerX - firstPointerX;\n var vectorY = secondPointerY - firstPointerY;\n this.anchorX = (firstPointerX + secondPointerX) / 2;\n this.anchorY = (firstPointerY + secondPointerY) / 2;\n var angle = -Math.atan2(vectorY, vectorX);\n this.rotation = Number.isNaN(this.previousAngle) ? 0 : this.previousAngle - angle;\n this.previousAngle = angle;\n if (this.rotation > Math.PI) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI) {\n this.rotation += Math.PI;\n }\n if (this.rotation > Math.PI / 2) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI / 2) {\n this.rotation += Math.PI;\n }\n }\n }, {\n key: \"finish\",\n value: function finish() {\n if (!this.isInProgress) {\n return;\n }\n this.isInProgress = false;\n this.keyPointers = [NaN, NaN];\n this.onRotationEnd(this);\n }\n }, {\n key: \"setKeyPointers\",\n value: function setKeyPointers(tracker) {\n if (this.keyPointers[0] && this.keyPointers[1]) {\n return;\n }\n var pointerIDs = tracker.getData().keys();\n this.keyPointers[0] = pointerIDs.next().value;\n this.keyPointers[1] = pointerIDs.next().value;\n }\n }, {\n key: \"onTouchEvent\",\n value: function onTouchEvent(event, tracker) {\n switch (event.eventType) {\n case EventTypes.DOWN:\n this.isInProgress = false;\n break;\n case EventTypes.ADDITIONAL_POINTER_DOWN:\n if (this.isInProgress) {\n break;\n }\n this.isInProgress = true;\n this.previousTime = event.time;\n this.previousAngle = NaN;\n this.setKeyPointers(tracker);\n this.updateCurrent(event, tracker);\n this.onRotationBegin(this);\n break;\n case EventTypes.MOVE:\n if (!this.isInProgress) {\n break;\n }\n this.updateCurrent(event, tracker);\n this.onRotation(this);\n break;\n case EventTypes.ADDITIONAL_POINTER_UP:\n if (!this.isInProgress) {\n break;\n }\n if (this.keyPointers.indexOf(event.pointerId) >= 0) {\n this.finish();\n }\n break;\n case EventTypes.UP:\n if (this.isInProgress) {\n this.finish();\n }\n break;\n }\n return true;\n }\n }, {\n key: \"getTimeDelta\",\n value: function getTimeDelta() {\n return this.currentTime + this.previousTime;\n }\n }, {\n key: \"getAnchorX\",\n value: function getAnchorX() {\n return this.anchorX;\n }\n }, {\n key: \"getAnchorY\",\n value: function getAnchorY() {\n return this.anchorY;\n }\n }, {\n key: \"getRotation\",\n value: function getRotation() {\n return this.rotation;\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this.keyPointers = [NaN, NaN];\n this.isInProgress = false;\n }\n }]);\n return RotationGestureDetector;\n}();\nexport { RotationGestureDetector as default };","map":{"version":3,"mappings":";;;;;;;;;;;;;;;;AAAA,SAAuBA,UAAvB;AAAA,IASqBC,uBAAN;EAoBbC,iCAAYC,SAAD,EAAqC;IAAA;IAAAC;IAAAA;IAAAA;IAAAA,qCAb1B,CAa0B;IAAAA,sCAZzB,CAYyB;IAAAA,uCAVxB,CAUwB;IAAAA,kCAT7B,CAS6B;IAAAA,iCAP9B,CAO8B;IAAAA,iCAN9B,CAM8B;IAAAA,sCAJzB,KAIyB;IAAAA,qCAFhB,CAACC,GAAD,EAAMA,GAAN,CAEgB;IAC9C,KAAKC,eAAL,GAAuBH,SAAS,CAACG,eAAjC;IACA,KAAKC,UAAL,GAAkBJ,SAAS,CAACI,UAA5B;IACA,KAAKC,aAAL,GAAqBL,SAAS,CAACK,aAA/B;EACD;EAAA;IAAA;IAAA,OAEOC,uBAAcC,KAAD,EAAsBC,OAAtB,EAAqD;MACxE,KAAKC,YAAL,GAAoB,KAAKC,WAAzB;MACA,KAAKA,WAAL,GAAmBH,KAAK,CAACI,IAAzB;MAEA,uCAA0C,KAAKC,WAA/C;QAAOC,cAAD;QAAiBC,eAAjB;MAEN,IAAMC,aAAqB,GAAGP,OAAO,CAACQ,QAAR,CAAiBH,cAAjB,CAA9B;MACA,IAAMI,aAAqB,GAAGT,OAAO,CAACU,QAAR,CAAiBL,cAAjB,CAA9B;MACA,IAAMM,cAAsB,GAAGX,OAAO,CAACQ,QAAR,CAAiBF,eAAjB,CAA/B;MACA,IAAMM,cAAsB,GAAGZ,OAAO,CAACU,QAAR,CAAiBJ,eAAjB,CAA/B;MAEA,IAAMO,OAAe,GAAGF,cAAc,GAAGJ,aAAzC;MACA,IAAMO,OA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AAO,IAAP;IACD;EAAA;IAAA;IAAA,OAEMiB,wBAAuB;MAC5B,OAAO,KAAKxC,WAAL,GAAmB,KAAKD,YAA/B;IACD;EAAA;IAAA;IAAA,OAEM0C,sBAAqB;MAC1B,OAAO,KAAK5B,OAAZ;IACD;EAAA;IAAA;IAAA,OAEM6B,sBAAqB;MAC1B,OAAO,KAAK5B,OAAZ;IACD;EAAA;IAAA;IAAA,OAEM6B,uBAAsB;MAC3B,OAAO,KAAKzB,QAAZ;IACD;EAAA;IAAA;IAAA,OAEM0B,iBAAc;MACnB,KAAK1C,WAAL,GAAmB,CAACV,GAAD,EAAMA,GAAN,CAAnB;MACA,KAAKgC,YAAL,GAAoB,KAApB;IACD;EAAA;EAAA;AAAA;AAAA,SA7JkBpC,uBAAN","names":["EventTypes","RotationGestureDetector","constructor","callbacks","_defineProperty","NaN","onRotationBegin","onRotation","onRotationEnd","updateCurrent","event","tracker","previousTime","currentTime","time","keyPointers","firstPointerID","secondPointerID","firstPointerX","getLastX","firstPointerY","getLastY","secondPointerX","secondPointerY","vectorX","vectorY","anchorX","anchorY","angle","Math","atan2","rotation","Number","isNaN","previousAngle","PI","finish","isInProgress","setKeyPointers","pointerIDs","getData","keys","next","value","onTouchEvent","eventType","DOWN","ADDITIONAL_POINTER_DOWN","MOVE","ADDITIONAL_POINTER_UP","indexOf","pointerId","UP","getTimeDelta","getAnchorX","getAnchorY","getRotation","reset"],"sources":["/Users/mathildejean/Documents/BUT/LaSuperMeteo/LaSuperMeteo/iut-expo-starter/node_modules/react-native-gesture-handler/lib/module/web/detectors/RotationGestureDetector.ts"],"sourcesContent":["import { AdaptedEvent, EventTypes } from '../interfaces';\nimport PointerTracker from '../tools/PointerTracker';\n\nexport interface RotationGestureListener {\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n}\n\nexport default class RotationGestureDetector\n implements RotationGestureListener\n{\n onRotationBegin: (detector: RotationGestureDetector) => boolean;\n onRotation: (detector: RotationGestureDetector) => boolean;\n onRotationEnd: (detector: RotationGestureDetector) => void;\n\n private currentTime = 0;\n private previousTime = 0;\n\n private previousAngle = 0;\n private rotation = 0;\n\n private anchorX = 0;\n private anchorY = 0;\n\n private isInProgress = false;\n\n private keyPointers: number[] = [NaN, NaN];\n\n constructor(callbacks: RotationGestureListener) {\n this.onRotationBegin = callbacks.onRotationBegin;\n this.onRotation = callbacks.onRotation;\n this.onRotationEnd = callbacks.onRotationEnd;\n }\n\n private updateCurrent(event: AdaptedEvent, tracker: PointerTracker): void {\n this.previousTime = this.currentTime;\n this.currentTime = event.time;\n\n const [firstPointerID, secondPointerID] = this.keyPointers;\n\n const firstPointerX: number = tracker.getLastX(firstPointerID);\n const firstPointerY: number = tracker.getLastY(firstPointerID);\n const secondPointerX: number = tracker.getLastX(secondPointerID);\n const secondPointerY: number = tracker.getLastY(secondPointerID);\n\n const vectorX: number = secondPointerX - firstPointerX;\n const vectorY: number = secondPointerY - firstPointerY;\n\n this.anchorX = (firstPointerX + secondPointerX) / 2;\n this.anchorY = (firstPointerY + secondPointerY) / 2;\n\n //Angle diff should be positive when rotating in clockwise direction\n const angle: number = -Math.atan2(vectorY, vectorX);\n\n this.rotation = Number.isNaN(this.previousAngle)\n ? 0\n : this.previousAngle - angle;\n\n this.previousAngle = angle;\n\n if (this.rotation > Math.PI) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI) {\n this.rotation += Math.PI;\n }\n\n if (this.rotation > Math.PI / 2) {\n this.rotation -= Math.PI;\n } else if (this.rotation < -Math.PI / 2) {\n this.rotation += Math.PI;\n }\n }\n\n private finish(): void {\n if (!this.isInProgress) {\n return;\n }\n\n this.isInProgress = false;\n this.keyPointers = [NaN, NaN];\n this.onRotationEnd(this);\n }\n\n private setKeyPointers(tracker: PointerTracker): void {\n if (this.keyPointers[0] && this.keyPointers[1]) {\n return;\n }\n\n const pointerIDs: IterableIterator<number> = tracker.getData().keys();\n\n this.keyPointers[0] = pointerIDs.next().value as number;\n this.keyPointers[1] = pointerIDs.next().value as number;\n }\n\n public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {\n switch (event.eventType) {\n case EventTypes.DOWN:\n this.isInProgress = false;\n break;\n\n case EventTypes.ADDITIONAL_POINTER_DOWN:\n if (this.isInProgress) {\n break;\n }\n this.isInProgress = true;\n\n this.previousTime = event.time;\n this.previousAngle = NaN;\n\n this.setKeyPointers(tracker);\n\n this.updateCurrent(event, tracker);\n this.onRotationBegin(this);\n break;\n\n case EventTypes.MOVE:\n if (!this.isInProgress) {\n break;\n }\n\n this.updateCurrent(event, tracker);\n this.onRotation(this);\n\n break;\n\n case EventTypes.ADDITIONAL_POINTER_UP:\n if (!this.isInProgress) {\n break;\n }\n\n if (this.keyPointers.indexOf(event.pointerId) >= 0) {\n this.finish();\n }\n\n break;\n\n case EventTypes.UP:\n if (this.isInProgress) {\n this.finish();\n }\n break;\n }\n\n return true;\n }\n\n public getTimeDelta(): number {\n return this.currentTime + this.previousTime;\n }\n\n public getAnchorX(): number {\n return this.anchorX;\n }\n\n public getAnchorY(): number {\n return this.anchorY;\n }\n\n public getRotation(): number {\n return this.rotation;\n }\n\n public reset(): void {\n this.keyPointers = [NaN, NaN];\n this.isInProgress = false;\n }\n}\n"]},"metadata":{},"sourceType":"module","externalDependencies":[]} |