react-native-gesture-handler 2.16.2 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/android/build.gradle +103 -0
- package/android/gradle.properties +7 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +7 -7
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +16 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -5
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +4 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +1 -0
- package/apple/RNGestureHandlerButtonComponentView.mm +10 -0
- package/apple/RNGestureHandlerModule.mm +2 -3
- package/lib/commonjs/components/GestureButtons.js +27 -12
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +1 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +3 -3
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js +42 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +83 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +143 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js +25 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js +6 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +80 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +180 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +55 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +47 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +176 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gestureComposition.js +3 -1
- package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/commonjs/utils.js +36 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +56 -64
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +28 -18
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +18 -12
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +7 -2
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +89 -57
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +6 -2
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/Vector.js +2 -1
- package/lib/commonjs/web/tools/Vector.js.map +1 -1
- package/lib/commonjs/web/utils.js +31 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/components/GestureButtons.js +24 -6
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/handlers/createHandler.js +2 -4
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js +26 -0
- package/lib/module/handlers/gestures/GestureDetector/Wrap.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +65 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +115 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
- package/lib/module/handlers/gestures/GestureDetector/needsToReattach.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/types.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +64 -0
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +165 -0
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +41 -0
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +36 -0
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js +142 -0
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -0
- package/lib/module/handlers/gestures/gestureComposition.js +3 -1
- package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +8 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
- package/lib/module/utils.js +34 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/detectors/RotationGestureDetector.js +6 -8
- package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
- package/lib/module/web/detectors/ScaleGestureDetector.js +5 -6
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +1 -0
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +56 -64
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +1 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +7 -4
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +28 -18
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +1 -0
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +1 -0
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +18 -12
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -6
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +8 -3
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +89 -57
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +7 -3
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/tools/Vector.js +2 -1
- package/lib/module/web/tools/Vector.js.map +1 -1
- package/lib/module/web/utils.js +29 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +3 -34
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -2
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +13 -0
- package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +2 -0
- package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts} +4 -12
- package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +20 -0
- package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +4 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +2 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +5 -0
- package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +3 -0
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +12 -0
- package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -1
- package/lib/typescript/utils.d.ts +10 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +34 -31
- package/lib/typescript/web/utils.d.ts +4 -0
- package/package.json +5 -5
- package/src/components/GestureButtons.tsx +36 -4
- package/src/handlers/createHandler.tsx +1 -3
- package/src/handlers/gestureHandlerCommon.ts +4 -1
- package/src/handlers/gestures/GestureDetector/Wrap.tsx +35 -0
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +112 -0
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +14 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +187 -0
- package/src/handlers/gestures/GestureDetector/needsToReattach.ts +27 -0
- package/src/handlers/gestures/GestureDetector/types.ts +32 -0
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +94 -0
- package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +206 -0
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +69 -0
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +54 -0
- package/src/handlers/gestures/GestureDetector/utils.ts +185 -0
- package/src/handlers/gestures/gestureComposition.ts +2 -0
- package/src/handlers/gestures/gestureStateManager.ts +12 -4
- package/src/handlers/gestures/reanimatedWrapper.ts +19 -17
- package/src/utils.ts +39 -0
- package/src/web/detectors/RotationGestureDetector.ts +6 -8
- package/src/web/detectors/ScaleGestureDetector.ts +5 -6
- package/src/web/handlers/FlingGestureHandler.ts +2 -0
- package/src/web/handlers/GestureHandler.ts +53 -62
- package/src/web/handlers/LongPressGestureHandler.ts +2 -0
- package/src/web/handlers/ManualGestureHandler.ts +2 -0
- package/src/web/handlers/NativeViewGestureHandler.ts +8 -4
- package/src/web/handlers/PanGestureHandler.ts +32 -19
- package/src/web/handlers/PinchGestureHandler.ts +2 -0
- package/src/web/handlers/RotationGestureHandler.ts +2 -0
- package/src/web/handlers/TapGestureHandler.ts +20 -12
- package/src/web/interfaces.ts +1 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
- package/src/web/tools/PointerEventManager.ts +10 -3
- package/src/web/tools/PointerTracker.ts +81 -74
- package/src/web/tools/TouchEventManager.ts +5 -3
- package/src/web/tools/Vector.ts +2 -4
- package/src/web/utils.ts +34 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -704
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/module/handlers/gestures/GestureDetector.js +0 -654
- package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
- package/src/handlers/gestures/GestureDetector.tsx +0 -889
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Vector.ts"],"names":["DiagonalDirections","Directions","MINIMAL_FLING_VELOCITY","Vector","constructor","x","y","_magnitude","Math","hypot","isMagnitudeSufficient","unitX","unitY","fromDirection","direction","DirectionToVectorMappings","get","fromVelocity","tracker","pointerId","
|
|
1
|
+
{"version":3,"sources":["Vector.ts"],"names":["DiagonalDirections","Directions","MINIMAL_FLING_VELOCITY","Vector","constructor","x","y","_magnitude","Math","hypot","isMagnitudeSufficient","unitX","unitY","fromDirection","direction","DirectionToVectorMappings","get","fromVelocity","tracker","pointerId","velocity","getVelocity","magnitude","computeSimilarity","vector","isSimilar","threshold","Map","LEFT","RIGHT","UP","DOWN","UP_RIGHT","DOWN_RIGHT","UP_LEFT","DOWN_LEFT"],"mappings":";;AAAA,SAASA,kBAAT,EAA6BC,UAA7B,QAA+C,kBAA/C;AACA,SAASC,sBAAT,QAAuC,cAAvC;AAGA,eAAe,MAAMC,MAAN,CAAa;AAO1BC,EAAAA,WAAW,CAACC,CAAD,EAAYC,CAAZ,EAAuB;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAChC,SAAKD,CAAL,GAASA,CAAT;AACA,SAAKC,CAAL,GAASA,CAAT;AAEA,SAAKC,UAAL,GAAkBC,IAAI,CAACC,KAAL,CAAW,KAAKJ,CAAhB,EAAmB,KAAKC,CAAxB,CAAlB;AACA,UAAMI,qBAAqB,GAAG,KAAKH,UAAL,GAAkBL,sBAAhD;AAEA,SAAKS,KAAL,GAAaD,qBAAqB,GAAG,KAAKL,CAAL,GAAS,KAAKE,UAAjB,GAA8B,CAAhE;AACA,SAAKK,KAAL,GAAaF,qBAAqB,GAAG,KAAKJ,CAAL,GAAS,KAAKC,UAAjB,GAA8B,CAAhE;AACD;;AAEmB,SAAbM,aAAa,CAACC,SAAD,EAAqD;AACvE,WAAOC,yBAAyB,CAACC,GAA1B,CAA8BF,SAA9B,CAAP;AACD;;AAEkB,SAAZG,YAAY,CAACC,OAAD,EAA0BC,SAA1B,EAA6C;AAC9D,UAAMC,QAAQ,GAAGF,OAAO,CAACG,WAAR,CAAoBF,SAApB,CAAjB;AACA,WAAO,IAAIhB,MAAJ,CAAWiB,QAAQ,CAACf,CAApB,EAAuBe,QAAQ,CAACd,CAAhC,CAAP;AACD;;AAEY,MAATgB,SAAS,GAAG;AACd,WAAO,KAAKf,UAAZ;AACD;;AAEDgB,EAAAA,iBAAiB,CAACC,MAAD,EAAiB;AAChC,WAAO,KAAKb,KAAL,GAAaa,MAAM,CAACb,KAApB,GAA4B,KAAKC,KAAL,GAAaY,MAAM,CAACZ,KAAvD;AACD;;AAEDa,EAAAA,SAAS,CAACD,MAAD,EAAiBE,SAAjB,EAAoC;AAC3C,WAAO,KAAKH,iBAAL,CAAuBC,MAAvB,IAAiCE,SAAxC;AACD;;AArCyB;AAwC5B,MAAMX,yBAAyB,GAAG,IAAIY,GAAJ,CAGhC,CACA,CAAC1B,UAAU,CAAC2B,IAAZ,EAAkB,IAAIzB,MAAJ,CAAW,CAAC,CAAZ,EAAe,CAAf,CAAlB,CADA,EAEA,CAACF,UAAU,CAAC4B,KAAZ,EAAmB,IAAI1B,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAnB,CAFA,EAGA,CAACF,UAAU,CAAC6B,EAAZ,EAAgB,IAAI3B,MAAJ,CAAW,CAAX,EAAc,CAAC,CAAf,CAAhB,CAHA,EAIA,CAACF,UAAU,CAAC8B,IAAZ,EAAkB,IAAI5B,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAlB,CAJA,EAMA,CAACH,kBAAkB,CAACgC,QAApB,EAA8B,IAAI7B,MAAJ,CAAW,CAAX,EAAc,CAAC,CAAf,CAA9B,CANA,EAOA,CAACH,kBAAkB,CAACiC,UAApB,EAAgC,IAAI9B,MAAJ,CAAW,CAAX,EAAc,CAAd,CAAhC,CAPA,EAQA,CAACH,kBAAkB,CAACkC,OAApB,EAA6B,IAAI/B,MAAJ,CAAW,CAAC,CAAZ,EAAe,CAAC,CAAhB,CAA7B,CARA,EASA,CAACH,kBAAkB,CAACmC,SAApB,EAA+B,IAAIhC,MAAJ,CAAW,CAAC,CAAZ,EAAe,CAAf,CAA/B,CATA,CAHgC,CAAlC","sourcesContent":["import { DiagonalDirections, Directions } from '../../Directions';\nimport { MINIMAL_FLING_VELOCITY } from '../constants';\nimport PointerTracker from './PointerTracker';\n\nexport default class Vector {\n private readonly x;\n private readonly y;\n private readonly unitX;\n private readonly unitY;\n private readonly _magnitude;\n\n constructor(x: number, y: number) {\n this.x = x;\n this.y = y;\n\n this._magnitude = Math.hypot(this.x, this.y);\n const isMagnitudeSufficient = this._magnitude > MINIMAL_FLING_VELOCITY;\n\n this.unitX = isMagnitudeSufficient ? this.x / this._magnitude : 0;\n this.unitY = isMagnitudeSufficient ? this.y / this._magnitude : 0;\n }\n\n static fromDirection(direction: Directions | DiagonalDirections): Vector {\n return DirectionToVectorMappings.get(direction)!;\n }\n\n static fromVelocity(tracker: PointerTracker, pointerId: number) {\n const velocity = tracker.getVelocity(pointerId);\n return new Vector(velocity.x, velocity.y);\n }\n\n get magnitude() {\n return this._magnitude;\n }\n\n computeSimilarity(vector: Vector) {\n return this.unitX * vector.unitX + this.unitY * vector.unitY;\n }\n\n isSimilar(vector: Vector, threshold: number) {\n return this.computeSimilarity(vector) > threshold;\n }\n}\n\nconst DirectionToVectorMappings = new Map<\n Directions | DiagonalDirections,\n Vector\n>([\n [Directions.LEFT, new Vector(-1, 0)],\n [Directions.RIGHT, new Vector(1, 0)],\n [Directions.UP, new Vector(0, -1)],\n [Directions.DOWN, new Vector(0, 1)],\n\n [DiagonalDirections.UP_RIGHT, new Vector(1, -1)],\n [DiagonalDirections.DOWN_RIGHT, new Vector(1, 1)],\n [DiagonalDirections.UP_LEFT, new Vector(-1, -1)],\n [DiagonalDirections.DOWN_LEFT, new Vector(-1, 1)],\n]);\n"]}
|
package/lib/module/web/utils.js
CHANGED
|
@@ -9,4 +9,33 @@ export function isPointerInBounds(view, {
|
|
|
9
9
|
export const PointerTypeMapping = new Map([['mouse', PointerType.MOUSE], ['touch', PointerType.TOUCH], ['pen', PointerType.STYLUS], ['none', PointerType.OTHER]]);
|
|
10
10
|
export const degToRad = degrees => degrees * Math.PI / 180;
|
|
11
11
|
export const coneToDeviation = degrees => Math.cos(degToRad(degrees / 2));
|
|
12
|
+
export function calculateViewScale(view) {
|
|
13
|
+
var _RegExp$exec;
|
|
14
|
+
|
|
15
|
+
const styles = getComputedStyle(view);
|
|
16
|
+
const resultScales = {
|
|
17
|
+
scaleX: 1,
|
|
18
|
+
scaleY: 1
|
|
19
|
+
};
|
|
20
|
+
const scales = styles.scale.split(' ');
|
|
21
|
+
|
|
22
|
+
if (scales[0] !== 'none') {
|
|
23
|
+
resultScales.scaleX = parseFloat(scales[0]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (scales[1]) {
|
|
27
|
+
resultScales.scaleY = parseFloat(scales[1]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const matrixElements = (_RegExp$exec = new RegExp(/matrix\((.+)\)/).exec(styles.transform)) === null || _RegExp$exec === void 0 ? void 0 : _RegExp$exec[1];
|
|
31
|
+
|
|
32
|
+
if (!matrixElements) {
|
|
33
|
+
return resultScales;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const matrixElementsArray = matrixElements.split(', ');
|
|
37
|
+
resultScales.scaleX *= parseFloat(matrixElementsArray[0]);
|
|
38
|
+
resultScales.scaleY *= parseFloat(matrixElementsArray[3]);
|
|
39
|
+
return resultScales;
|
|
40
|
+
}
|
|
12
41
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["PointerType","isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom","PointerTypeMapping","Map","MOUSE","TOUCH","STYLUS","OTHER","degToRad","degrees","Math","PI","coneToDeviation","cos"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B;AAGA,OAAO,SAASC,iBAAT,CAA2BC,IAA3B,EAA8C;AAAEC,EAAAA,CAAF;AAAKC,EAAAA;AAAL,CAA9C,EAAwE;AAC7E,QAAMC,IAAa,GAAGH,IAAI,CAACI,qBAAL,EAAtB;AAEA,SAAOH,CAAC,IAAIE,IAAI,CAACE,IAAV,IAAkBJ,CAAC,IAAIE,IAAI,CAACG,KAA5B,IAAqCJ,CAAC,IAAIC,IAAI,CAACI,GAA/C,IAAsDL,CAAC,IAAIC,IAAI,CAACK,MAAvE;AACD;AAED,OAAO,MAAMC,kBAAkB,GAAG,IAAIC,GAAJ,CAA6B,CAC7D,CAAC,OAAD,EAAUZ,WAAW,CAACa,KAAtB,CAD6D,EAE7D,CAAC,OAAD,EAAUb,WAAW,CAACc,KAAtB,CAF6D,EAG7D,CAAC,KAAD,EAAQd,WAAW,CAACe,MAApB,CAH6D,EAI7D,CAAC,MAAD,EAASf,WAAW,CAACgB,KAArB,CAJ6D,CAA7B,CAA3B;AAOP,OAAO,MAAMC,QAAQ,GAAIC,OAAD,IAAsBA,OAAO,GAAGC,IAAI,CAACC,EAAhB,GAAsB,GAA5D;AAEP,OAAO,MAAMC,eAAe,GAAIH,OAAD,IAC7BC,IAAI,CAACG,GAAL,CAASL,QAAQ,CAACC,OAAO,GAAG,CAAX,CAAjB,CADK","sourcesContent":["import { PointerType } from '../PointerType';\nimport { Point } from './interfaces';\n\nexport function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean {\n const rect: DOMRect = view.getBoundingClientRect();\n\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n}\n\nexport const PointerTypeMapping = new Map<string, PointerType>([\n ['mouse', PointerType.MOUSE],\n ['touch', PointerType.TOUCH],\n ['pen', PointerType.STYLUS],\n ['none', PointerType.OTHER],\n]);\n\nexport const degToRad = (degrees: number) => (degrees * Math.PI) / 180;\n\nexport const coneToDeviation = (degrees: number) =>\n Math.cos(degToRad(degrees / 2));\n"]}
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["PointerType","isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom","PointerTypeMapping","Map","MOUSE","TOUCH","STYLUS","OTHER","degToRad","degrees","Math","PI","coneToDeviation","cos","calculateViewScale","styles","getComputedStyle","resultScales","scaleX","scaleY","scales","scale","split","parseFloat","matrixElements","RegExp","exec","transform","matrixElementsArray"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B;AAGA,OAAO,SAASC,iBAAT,CAA2BC,IAA3B,EAA8C;AAAEC,EAAAA,CAAF;AAAKC,EAAAA;AAAL,CAA9C,EAAwE;AAC7E,QAAMC,IAAa,GAAGH,IAAI,CAACI,qBAAL,EAAtB;AAEA,SAAOH,CAAC,IAAIE,IAAI,CAACE,IAAV,IAAkBJ,CAAC,IAAIE,IAAI,CAACG,KAA5B,IAAqCJ,CAAC,IAAIC,IAAI,CAACI,GAA/C,IAAsDL,CAAC,IAAIC,IAAI,CAACK,MAAvE;AACD;AAED,OAAO,MAAMC,kBAAkB,GAAG,IAAIC,GAAJ,CAA6B,CAC7D,CAAC,OAAD,EAAUZ,WAAW,CAACa,KAAtB,CAD6D,EAE7D,CAAC,OAAD,EAAUb,WAAW,CAACc,KAAtB,CAF6D,EAG7D,CAAC,KAAD,EAAQd,WAAW,CAACe,MAApB,CAH6D,EAI7D,CAAC,MAAD,EAASf,WAAW,CAACgB,KAArB,CAJ6D,CAA7B,CAA3B;AAOP,OAAO,MAAMC,QAAQ,GAAIC,OAAD,IAAsBA,OAAO,GAAGC,IAAI,CAACC,EAAhB,GAAsB,GAA5D;AAEP,OAAO,MAAMC,eAAe,GAAIH,OAAD,IAC7BC,IAAI,CAACG,GAAL,CAASL,QAAQ,CAACC,OAAO,GAAG,CAAX,CAAjB,CADK;AAGP,OAAO,SAASK,kBAAT,CAA4BrB,IAA5B,EAA+C;AAAA;;AACpD,QAAMsB,MAAM,GAAGC,gBAAgB,CAACvB,IAAD,CAA/B;AAEA,QAAMwB,YAAY,GAAG;AACnBC,IAAAA,MAAM,EAAE,CADW;AAEnBC,IAAAA,MAAM,EAAE;AAFW,GAArB;AAKA,QAAMC,MAAM,GAAGL,MAAM,CAACM,KAAP,CAAaC,KAAb,CAAmB,GAAnB,CAAf;;AAEA,MAAIF,MAAM,CAAC,CAAD,CAAN,KAAc,MAAlB,EAA0B;AACxBH,IAAAA,YAAY,CAACC,MAAb,GAAsBK,UAAU,CAACH,MAAM,CAAC,CAAD,CAAP,CAAhC;AACD;;AAED,MAAIA,MAAM,CAAC,CAAD,CAAV,EAAe;AACbH,IAAAA,YAAY,CAACE,MAAb,GAAsBI,UAAU,CAACH,MAAM,CAAC,CAAD,CAAP,CAAhC;AACD;;AAED,QAAMI,cAAc,mBAAG,IAAIC,MAAJ,CAAW,gBAAX,EAA6BC,IAA7B,CACrBX,MAAM,CAACY,SADc,CAAH,iDAAG,aAEnB,CAFmB,CAAvB;;AAIA,MAAI,CAACH,cAAL,EAAqB;AACnB,WAAOP,YAAP;AACD;;AAED,QAAMW,mBAAmB,GAAGJ,cAAc,CAACF,KAAf,CAAqB,IAArB,CAA5B;AAEAL,EAAAA,YAAY,CAACC,MAAb,IAAuBK,UAAU,CAACK,mBAAmB,CAAC,CAAD,CAApB,CAAjC;AACAX,EAAAA,YAAY,CAACE,MAAb,IAAuBI,UAAU,CAACK,mBAAmB,CAAC,CAAD,CAApB,CAAjC;AAEA,SAAOX,YAAP;AACD","sourcesContent":["import { PointerType } from '../PointerType';\nimport { Point } from './interfaces';\n\nexport function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean {\n const rect: DOMRect = view.getBoundingClientRect();\n\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n}\n\nexport const PointerTypeMapping = new Map<string, PointerType>([\n ['mouse', PointerType.MOUSE],\n ['touch', PointerType.TOUCH],\n ['pen', PointerType.STYLUS],\n ['none', PointerType.OTHER],\n]);\n\nexport const degToRad = (degrees: number) => (degrees * Math.PI) / 180;\n\nexport const coneToDeviation = (degrees: number) =>\n Math.cos(degToRad(degrees / 2));\n\nexport function calculateViewScale(view: HTMLElement) {\n const styles = getComputedStyle(view);\n\n const resultScales = {\n scaleX: 1,\n scaleY: 1,\n };\n\n const scales = styles.scale.split(' ');\n\n if (scales[0] !== 'none') {\n resultScales.scaleX = parseFloat(scales[0]);\n }\n\n if (scales[1]) {\n resultScales.scaleY = parseFloat(scales[1]);\n }\n\n const matrixElements = new RegExp(/matrix\\((.+)\\)/).exec(\n styles.transform\n )?.[1];\n\n if (!matrixElements) {\n return resultScales;\n }\n\n const matrixElementsArray = matrixElements.split(', ');\n\n resultScales.scaleX *= parseFloat(matrixElementsArray[0]);\n resultScales.scaleY *= parseFloat(matrixElementsArray[3]);\n\n return resultScales;\n}\n"]}
|
|
@@ -84,38 +84,7 @@ export interface BorderlessButtonProps extends BaseButtonProps {
|
|
|
84
84
|
activeOpacity?: number;
|
|
85
85
|
}
|
|
86
86
|
export declare const RawButton: React.ForwardRefExoticComponent<RawButtonProps & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
|
|
87
|
-
export declare
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
private lastActive;
|
|
92
|
-
private longPressTimeout;
|
|
93
|
-
private longPressDetected;
|
|
94
|
-
constructor(props: BaseButtonProps);
|
|
95
|
-
private handleEvent;
|
|
96
|
-
private onLongPress;
|
|
97
|
-
private onHandlerStateChange;
|
|
98
|
-
private onGestureEvent;
|
|
99
|
-
render(): React.JSX.Element;
|
|
100
|
-
}
|
|
101
|
-
export declare class RectButton extends React.Component<RectButtonProps> {
|
|
102
|
-
static defaultProps: {
|
|
103
|
-
activeOpacity: number;
|
|
104
|
-
underlayColor: string;
|
|
105
|
-
};
|
|
106
|
-
private opacity;
|
|
107
|
-
constructor(props: RectButtonProps);
|
|
108
|
-
private onActiveStateChange;
|
|
109
|
-
render(): React.JSX.Element;
|
|
110
|
-
}
|
|
111
|
-
export declare class BorderlessButton extends React.Component<BorderlessButtonProps> {
|
|
112
|
-
static defaultProps: {
|
|
113
|
-
activeOpacity: number;
|
|
114
|
-
borderless: boolean;
|
|
115
|
-
};
|
|
116
|
-
private opacity;
|
|
117
|
-
constructor(props: BorderlessButtonProps);
|
|
118
|
-
private onActiveStateChange;
|
|
119
|
-
render(): React.JSX.Element;
|
|
120
|
-
}
|
|
87
|
+
export declare const BaseButton: React.ForwardRefExoticComponent<Omit<BaseButtonProps, "innerRef"> & React.RefAttributes<any>>;
|
|
88
|
+
export declare const RectButton: React.ForwardRefExoticComponent<Omit<RectButtonProps, "innerRef"> & React.RefAttributes<any>>;
|
|
89
|
+
export declare const BorderlessButton: React.ForwardRefExoticComponent<Omit<BorderlessButtonProps, "innerRef"> & React.RefAttributes<any>>;
|
|
121
90
|
export { default as PureNativeButton } from './GestureHandlerButton';
|
|
@@ -4,7 +4,7 @@ import { TouchEventType } from '../TouchEventType';
|
|
|
4
4
|
import { ValueOf } from '../typeUtils';
|
|
5
5
|
import { PointerType } from '../PointerType';
|
|
6
6
|
export declare const baseGestureHandlerProps: readonly ["id", "enabled", "shouldCancelWhenOutside", "hitSlop", "cancelsTouchesInView", "userSelect", "activeCursor", "mouseButton", "enableContextMenu", "touchAction", "waitFor", "simultaneousHandlers", "blocksHandlers", "onBegan", "onFailed", "onCancelled", "onActivated", "onEnded", "onGestureEvent", "onHandlerStateChange"];
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const baseGestureHandlerWithDetectorProps: string[];
|
|
8
8
|
export interface GestureEventPayload {
|
|
9
9
|
handlerTag: number;
|
|
10
10
|
numberOfPointers: number;
|
|
@@ -14,7 +14,7 @@ export interface GestureEventPayload {
|
|
|
14
14
|
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
|
15
15
|
oldState: ValueOf<typeof State>;
|
|
16
16
|
}
|
|
17
|
-
export type HitSlop = number | Partial<Record<'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal', number>> | Record<'width' | 'left', number> | Record<'width' | 'right', number> | Record<'height' | 'top', number> | Record<'height' | 'bottom', number>;
|
|
17
|
+
export type HitSlop = number | null | undefined | Partial<Record<'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal', number>> | Record<'width' | 'left', number> | Record<'width' | 'right', number> | Record<'height' | 'top', number> | Record<'height' | 'bottom', number>;
|
|
18
18
|
export type UserSelect = 'none' | 'auto' | 'text';
|
|
19
19
|
export type ActiveCursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out';
|
|
20
20
|
export declare enum MouseButton {
|
|
@@ -46,6 +46,7 @@ export type GestureTouchEvent = {
|
|
|
46
46
|
eventType: TouchEventType;
|
|
47
47
|
allTouches: TouchData[];
|
|
48
48
|
changedTouches: TouchData[];
|
|
49
|
+
pointerType: PointerType;
|
|
49
50
|
};
|
|
50
51
|
export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> = GestureEventPayload & GestureEventPayloadT;
|
|
51
52
|
export type GestureStateChangeEvent<GestureStateChangeEventPayloadT = Record<string, unknown>> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare class Wrap extends React.Component<{
|
|
3
|
+
onGestureHandlerEvent?: unknown;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}> {
|
|
6
|
+
render(): React.FunctionComponentElement<{
|
|
7
|
+
collapsable: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare const AnimatedWrap: typeof Wrap | React.ComponentClass<{
|
|
11
|
+
onGestureHandlerEvent?: unknown;
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
}, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GestureType } from '../gesture';
|
|
3
|
+
import { ComposedGesture } from '../gestureComposition';
|
|
4
|
+
import { AttachedGestureState, WebEventHandler } from './types';
|
|
5
|
+
interface AttachHandlersConfig {
|
|
6
|
+
preparedGesture: AttachedGestureState;
|
|
7
|
+
gestureConfig: ComposedGesture | GestureType;
|
|
8
|
+
gesturesToAttach: GestureType[];
|
|
9
|
+
viewTag: number;
|
|
10
|
+
webEventHandlersRef: React.RefObject<WebEventHandler>;
|
|
11
|
+
}
|
|
12
|
+
export declare function attachHandlers({ preparedGesture, gestureConfig, gesturesToAttach, viewTag, webEventHandlersRef, }: AttachHandlersConfig): void;
|
|
13
|
+
export {};
|
package/lib/typescript/handlers/gestures/{GestureDetector.d.ts → GestureDetector/index.d.ts}
RENAMED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { GestureType
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ComposedGesture } from './gestureComposition';
|
|
6
|
-
export type GestureConfigReference = {
|
|
7
|
-
config: GestureType[];
|
|
8
|
-
animatedEventHandler: unknown;
|
|
9
|
-
animatedHandlers: SharedValue<HandlerCallbacks<Record<string, unknown>>[] | null> | null;
|
|
10
|
-
firstExecution: boolean;
|
|
11
|
-
useReanimatedHook: boolean;
|
|
12
|
-
};
|
|
2
|
+
import { GestureType } from '../gesture';
|
|
3
|
+
import { UserSelect, TouchAction } from '../../gestureHandlerCommon';
|
|
4
|
+
import { ComposedGesture } from '../gestureComposition';
|
|
13
5
|
interface GestureDetectorProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
14
7
|
/**
|
|
15
8
|
* A gesture object containing the configuration and callbacks.
|
|
16
9
|
* Can be any of:
|
|
@@ -18,7 +11,6 @@ interface GestureDetectorProps {
|
|
|
18
11
|
* - `ComposedGesture` (`Race`, `Simultaneous`, `Exclusive`)
|
|
19
12
|
*/
|
|
20
13
|
gesture: ComposedGesture | GestureType;
|
|
21
|
-
children?: React.ReactNode;
|
|
22
14
|
/**
|
|
23
15
|
* #### Web only
|
|
24
16
|
* This parameter allows to specify which `userSelect` property should be applied to underlying view.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GestureType, HandlerCallbacks } from '../gesture';
|
|
2
|
+
import { SharedValue } from '../reanimatedWrapper';
|
|
3
|
+
import { HandlerStateChangeEvent } from '../../gestureHandlerCommon';
|
|
4
|
+
export interface AttachedGestureState {
|
|
5
|
+
attachedGestures: GestureType[];
|
|
6
|
+
animatedEventHandler: unknown;
|
|
7
|
+
animatedHandlers: SharedValue<HandlerCallbacks<Record<string, unknown>>[] | null> | null;
|
|
8
|
+
shouldUseReanimated: boolean;
|
|
9
|
+
isMounted: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface GestureDetectorState {
|
|
12
|
+
firstRender: boolean;
|
|
13
|
+
viewRef: React.Component | null;
|
|
14
|
+
previousViewTag: number;
|
|
15
|
+
forceRebuildReanimatedEvent: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface WebEventHandler {
|
|
18
|
+
onGestureHandlerEvent: (event: HandlerStateChangeEvent<unknown>) => void;
|
|
19
|
+
onGestureHandlerStateChange?: (event: HandlerStateChangeEvent<unknown>) => void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GestureType } from '../gesture';
|
|
2
|
+
import { ComposedGesture } from '../gestureComposition';
|
|
3
|
+
import { AttachedGestureState } from './types';
|
|
4
|
+
export declare function updateHandlers(preparedGesture: AttachedGestureState, gestureConfig: ComposedGesture | GestureType, newGestures: GestureType[]): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GestureType } from '../gesture';
|
|
3
|
+
import { ComposedGesture } from '../gestureComposition';
|
|
4
|
+
import { AttachedGestureState, GestureDetectorState, WebEventHandler } from './types';
|
|
5
|
+
export declare function useDetectorUpdater(state: GestureDetectorState, preparedGesture: AttachedGestureState, gesturesToAttach: GestureType[], gestureConfig: ComposedGesture | GestureType, webEventHandlersRef: React.RefObject<WebEventHandler>): (skipConfigUpdate?: boolean) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GestureType } from '../gesture';
|
|
2
|
+
import { WebEventHandler } from './types';
|
|
3
|
+
export declare const ALLOWED_PROPS: string[];
|
|
4
|
+
export declare function extractGestureRelations(gesture: GestureType): {
|
|
5
|
+
waitFor: number[];
|
|
6
|
+
simultaneousHandlers: number[];
|
|
7
|
+
blocksHandlers: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare function checkGestureCallbacksForWorklets(gesture: GestureType): void;
|
|
10
|
+
export declare function validateDetectorChildren(ref: any): void;
|
|
11
|
+
export declare function useForceRender(): () => void;
|
|
12
|
+
export declare function useWebEventHandlers(): import("react").MutableRefObject<WebEventHandler>;
|
|
@@ -10,5 +10,5 @@ declare let Reanimated: {
|
|
|
10
10
|
useEvent: (callback: (event: GestureUpdateEvent | GestureStateChangeEvent) => void, events: string[], rebuild: boolean) => unknown;
|
|
11
11
|
useSharedValue: <T>(value: T) => SharedValue<T>;
|
|
12
12
|
setGestureState: (handlerTag: number, newState: number) => void;
|
|
13
|
-
};
|
|
13
|
+
} | undefined;
|
|
14
14
|
export { Reanimated };
|
|
@@ -6,3 +6,13 @@ export declare function isJestEnv(): boolean;
|
|
|
6
6
|
export declare function tagMessage(msg: string): string;
|
|
7
7
|
export declare function isFabric(): boolean;
|
|
8
8
|
export declare function isRemoteDebuggingEnabled(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Recursively compares two objects for deep equality.
|
|
11
|
+
*
|
|
12
|
+
* **Note:** This function does not support cyclic references.
|
|
13
|
+
*
|
|
14
|
+
* @param obj1 - The first object to compare.
|
|
15
|
+
* @param obj2 - The second object to compare.
|
|
16
|
+
* @returns `true` if the objects are deeply equal, `false` otherwise.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deepEqual(obj1: any, obj2: any): boolean;
|
|
@@ -67,6 +67,7 @@ export default abstract class GestureHandler implements IGestureHandler {
|
|
|
67
67
|
protected onPointerMoveOver(_event: AdaptedEvent): void;
|
|
68
68
|
protected onPointerMoveOut(_event: AdaptedEvent): void;
|
|
69
69
|
private tryToSendMoveEvent;
|
|
70
|
+
protected tryToSendTouchEvent(event: AdaptedEvent): void;
|
|
70
71
|
sendTouchEvent(event: AdaptedEvent): void;
|
|
71
72
|
sendEvent: (newState: State, oldState: State) => void;
|
|
72
73
|
private transformEventData;
|
|
@@ -88,6 +88,7 @@ interface NativeTouchEvent extends Record<string, TouchNativeArgs> {
|
|
|
88
88
|
changedTouches: PointerData[];
|
|
89
89
|
allTouches: PointerData[];
|
|
90
90
|
numberOfTouches: number;
|
|
91
|
+
pointerType: PointerType;
|
|
91
92
|
}
|
|
92
93
|
export interface ResultEvent extends Record<string, NativeEvent | number> {
|
|
93
94
|
nativeEvent: NativeEvent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AdaptedEvent } from '../interfaces';
|
|
1
|
+
import { AdaptedEvent, Point } from '../interfaces';
|
|
2
2
|
export interface TrackerElement {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
abosoluteCoords: Point;
|
|
4
|
+
relativeCoords: Point;
|
|
5
|
+
timestamp: number;
|
|
6
6
|
velocityX: number;
|
|
7
7
|
velocityY: number;
|
|
8
8
|
}
|
|
@@ -11,7 +11,8 @@ export default class PointerTracker {
|
|
|
11
11
|
private trackedPointers;
|
|
12
12
|
private touchEventsIds;
|
|
13
13
|
private lastMovedPointerId;
|
|
14
|
-
private
|
|
14
|
+
private cachedAbsoluteAverages;
|
|
15
|
+
private cachedRelativeAverages;
|
|
15
16
|
constructor();
|
|
16
17
|
addToTracker(event: AdaptedEvent): void;
|
|
17
18
|
removeFromTracker(pointerId: number): void;
|
|
@@ -19,32 +20,34 @@ export default class PointerTracker {
|
|
|
19
20
|
private mapTouchEventId;
|
|
20
21
|
private removeMappedTouchId;
|
|
21
22
|
getMappedTouchEventId(touchEventId: number): number;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
getVelocity(pointerId: number): {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
getLastAbsoluteCoords(pointerId?: number): {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
};
|
|
31
|
+
getLastRelativeCoords(pointerId?: number): {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
};
|
|
35
|
+
getAbsoluteCoordsAverage(): {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
};
|
|
39
|
+
getRelativeCoordsAverage(): {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
getAbsoluteCoordsSum(ignoredPointer?: number): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
getRelativeCoordsSum(ignoredPointer?: number): {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
};
|
|
48
51
|
getTrackedPointersCount(): number;
|
|
49
52
|
getTrackedPointersID(): number[];
|
|
50
53
|
getData(): Map<number, TrackerElement>;
|
|
@@ -4,3 +4,7 @@ export declare function isPointerInBounds(view: HTMLElement, { x, y }: Point): b
|
|
|
4
4
|
export declare const PointerTypeMapping: Map<string, PointerType>;
|
|
5
5
|
export declare const degToRad: (degrees: number) => number;
|
|
6
6
|
export declare const coneToDeviation: (degrees: number) => number;
|
|
7
|
+
export declare function calculateViewScale(view: HTMLElement): {
|
|
8
|
+
scaleX: number;
|
|
9
|
+
scaleY: number;
|
|
10
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gesture-handler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.1",
|
|
4
4
|
"description": "Experimental implementation of a new declarative API for gesture handling in react-native",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "bob build && husky install",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"format:ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
|
|
15
15
|
"lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src MacOSExample/src && yarn prettier --check './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
|
|
16
16
|
"lint:js-root": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",
|
|
17
|
-
"lint:android": "./android/gradlew -p android spotlessCheck -q"
|
|
17
|
+
"lint:android": "./android/gradlew -p android spotlessCheck -q",
|
|
18
|
+
"checkIntegrity": "(cd ./FabricExample/android && ./gradlew generateCodegenArtifactsFromSchema -PskipCodegenCopyTask) && (cd ./android && ./gradlew checkIntegrityBetweenArchitectures)"
|
|
18
19
|
},
|
|
19
20
|
"react-native": "src/index.ts",
|
|
20
21
|
"main": "lib/commonjs/index.js",
|
|
@@ -62,7 +63,6 @@
|
|
|
62
63
|
"@egjs/hammerjs": "^2.0.17",
|
|
63
64
|
"hoist-non-react-statics": "^3.3.0",
|
|
64
65
|
"invariant": "^2.2.4",
|
|
65
|
-
"lodash": "^4.17.21",
|
|
66
66
|
"prop-types": "^15.7.2"
|
|
67
67
|
},
|
|
68
68
|
"jest": {
|
|
@@ -102,9 +102,9 @@
|
|
|
102
102
|
"prettier": "^2.7.1",
|
|
103
103
|
"react": "18.2.0",
|
|
104
104
|
"react-dom": "^16.12.0",
|
|
105
|
-
"react-native": "0.
|
|
105
|
+
"react-native": "0.74.1",
|
|
106
106
|
"react-native-builder-bob": "^0.17.1",
|
|
107
|
-
"react-native-reanimated": "^
|
|
107
|
+
"react-native-reanimated": "^3.12.0",
|
|
108
108
|
"react-native-web": "^0.11.7",
|
|
109
109
|
"react-test-renderer": "17.0.2",
|
|
110
110
|
"release-it": "^13.6.5",
|
|
@@ -65,6 +65,10 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
|
|
|
65
65
|
touchSoundDisabled?: boolean;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
interface ButtonWithRefProps {
|
|
69
|
+
innerRef?: React.ForwardedRef<React.ComponentType<any>>;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
export interface BaseButtonProps extends RawButtonProps {
|
|
69
73
|
/**
|
|
70
74
|
* Called when the button gets pressed (analogous to `onPress` in
|
|
@@ -94,6 +98,8 @@ export interface BaseButtonProps extends RawButtonProps {
|
|
|
94
98
|
delayLongPress?: number;
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
interface BaseButtonWithRefProps extends BaseButtonProps, ButtonWithRefProps {}
|
|
102
|
+
|
|
97
103
|
export interface RectButtonProps extends BaseButtonProps {
|
|
98
104
|
/**
|
|
99
105
|
* Background color that will be dimmed when button is in active state.
|
|
@@ -108,6 +114,8 @@ export interface RectButtonProps extends BaseButtonProps {
|
|
|
108
114
|
activeOpacity?: number;
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
interface RectButtonWithRefProps extends RectButtonProps, ButtonWithRefProps {}
|
|
118
|
+
|
|
111
119
|
export interface BorderlessButtonProps extends BaseButtonProps {
|
|
112
120
|
/**
|
|
113
121
|
* iOS only.
|
|
@@ -117,12 +125,16 @@ export interface BorderlessButtonProps extends BaseButtonProps {
|
|
|
117
125
|
activeOpacity?: number;
|
|
118
126
|
}
|
|
119
127
|
|
|
128
|
+
interface BorderlessButtonWithRefProps
|
|
129
|
+
extends BorderlessButtonProps,
|
|
130
|
+
ButtonWithRefProps {}
|
|
131
|
+
|
|
120
132
|
export const RawButton = createNativeWrapper(GestureHandlerButton, {
|
|
121
133
|
shouldCancelWhenOutside: false,
|
|
122
134
|
shouldActivateOnStart: false,
|
|
123
135
|
});
|
|
124
136
|
|
|
125
|
-
|
|
137
|
+
class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
|
|
126
138
|
static defaultProps = {
|
|
127
139
|
delayLongPress: 600,
|
|
128
140
|
};
|
|
@@ -222,6 +234,7 @@ export class BaseButton extends React.Component<BaseButtonProps> {
|
|
|
222
234
|
|
|
223
235
|
return (
|
|
224
236
|
<RawButton
|
|
237
|
+
ref={this.props.innerRef}
|
|
225
238
|
rippleColor={processColor(rippleColor)}
|
|
226
239
|
{...rest}
|
|
227
240
|
onGestureEvent={this.onGestureEvent}
|
|
@@ -231,6 +244,11 @@ export class BaseButton extends React.Component<BaseButtonProps> {
|
|
|
231
244
|
}
|
|
232
245
|
}
|
|
233
246
|
|
|
247
|
+
export const BaseButton = React.forwardRef<
|
|
248
|
+
any,
|
|
249
|
+
Omit<BaseButtonProps, 'innerRef'>
|
|
250
|
+
>((props, ref) => <InnerBaseButton innerRef={ref} {...props} />);
|
|
251
|
+
|
|
234
252
|
const AnimatedBaseButton = Animated.createAnimatedComponent(BaseButton);
|
|
235
253
|
|
|
236
254
|
const btnStyles = StyleSheet.create({
|
|
@@ -243,7 +261,7 @@ const btnStyles = StyleSheet.create({
|
|
|
243
261
|
},
|
|
244
262
|
});
|
|
245
263
|
|
|
246
|
-
|
|
264
|
+
class InnerRectButton extends React.Component<RectButtonWithRefProps> {
|
|
247
265
|
static defaultProps = {
|
|
248
266
|
activeOpacity: 0.105,
|
|
249
267
|
underlayColor: 'black',
|
|
@@ -272,6 +290,7 @@ export class RectButton extends React.Component<RectButtonProps> {
|
|
|
272
290
|
return (
|
|
273
291
|
<BaseButton
|
|
274
292
|
{...rest}
|
|
293
|
+
ref={this.props.innerRef}
|
|
275
294
|
style={resolvedStyle}
|
|
276
295
|
onActiveStateChange={this.onActiveStateChange}>
|
|
277
296
|
<Animated.View
|
|
@@ -294,7 +313,12 @@ export class RectButton extends React.Component<RectButtonProps> {
|
|
|
294
313
|
}
|
|
295
314
|
}
|
|
296
315
|
|
|
297
|
-
export
|
|
316
|
+
export const RectButton = React.forwardRef<
|
|
317
|
+
any,
|
|
318
|
+
Omit<RectButtonProps, 'innerRef'>
|
|
319
|
+
>((props, ref) => <InnerRectButton innerRef={ref} {...props} />);
|
|
320
|
+
|
|
321
|
+
class InnerBorderlessButton extends React.Component<BorderlessButtonWithRefProps> {
|
|
298
322
|
static defaultProps = {
|
|
299
323
|
activeOpacity: 0.3,
|
|
300
324
|
borderless: true,
|
|
@@ -316,11 +340,14 @@ export class BorderlessButton extends React.Component<BorderlessButtonProps> {
|
|
|
316
340
|
};
|
|
317
341
|
|
|
318
342
|
render() {
|
|
319
|
-
const { children, style, ...rest } = this.props;
|
|
343
|
+
const { children, style, innerRef, ...rest } = this.props;
|
|
320
344
|
|
|
321
345
|
return (
|
|
322
346
|
<AnimatedBaseButton
|
|
323
347
|
{...rest}
|
|
348
|
+
// @ts-ignore We don't want `innerRef` to be accessible from public API.
|
|
349
|
+
// However in this case we need to set it indirectly on `BaseButton`, hence we use ts-ignore
|
|
350
|
+
innerRef={innerRef}
|
|
324
351
|
onActiveStateChange={this.onActiveStateChange}
|
|
325
352
|
style={[style, Platform.OS === 'ios' && { opacity: this.opacity }]}>
|
|
326
353
|
{children}
|
|
@@ -329,4 +356,9 @@ export class BorderlessButton extends React.Component<BorderlessButtonProps> {
|
|
|
329
356
|
}
|
|
330
357
|
}
|
|
331
358
|
|
|
359
|
+
export const BorderlessButton = React.forwardRef<
|
|
360
|
+
any,
|
|
361
|
+
Omit<BorderlessButtonProps, 'innerRef'>
|
|
362
|
+
>((props, ref) => <InnerBorderlessButton innerRef={ref} {...props} />);
|
|
363
|
+
|
|
332
364
|
export { default as PureNativeButton } from './GestureHandlerButton';
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
EmitterSubscription,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { customDirectEventTypes } from './customDirectEventTypes';
|
|
9
|
-
// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
|
|
10
|
-
import deepEqual from 'lodash/isEqual';
|
|
11
9
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
|
12
10
|
import { State } from '../State';
|
|
13
11
|
import {
|
|
@@ -25,7 +23,7 @@ import {
|
|
|
25
23
|
scheduleFlushOperations,
|
|
26
24
|
} from './gestureHandlerCommon';
|
|
27
25
|
import { ValueOf } from '../typeUtils';
|
|
28
|
-
import { isFabric, isJestEnv, tagMessage } from '../utils';
|
|
26
|
+
import { deepEqual, isFabric, isJestEnv, tagMessage } from '../utils';
|
|
29
27
|
import { ActionType } from '../ActionType';
|
|
30
28
|
import { PressabilityDebugView } from './PressabilityDebugView';
|
|
31
29
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
|
@@ -45,7 +45,7 @@ export const baseGestureHandlerProps = [
|
|
|
45
45
|
'onHandlerStateChange',
|
|
46
46
|
] as const;
|
|
47
47
|
|
|
48
|
-
export const
|
|
48
|
+
export const baseGestureHandlerWithDetectorProps = [
|
|
49
49
|
...commonProps,
|
|
50
50
|
'needsPointerData',
|
|
51
51
|
'manualActivation',
|
|
@@ -63,6 +63,8 @@ export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
|
|
63
63
|
|
|
64
64
|
export type HitSlop =
|
|
65
65
|
| number
|
|
66
|
+
| null
|
|
67
|
+
| undefined
|
|
66
68
|
| Partial<
|
|
67
69
|
Record<
|
|
68
70
|
'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',
|
|
@@ -165,6 +167,7 @@ export type GestureTouchEvent = {
|
|
|
165
167
|
eventType: TouchEventType;
|
|
166
168
|
allTouches: TouchData[];
|
|
167
169
|
changedTouches: TouchData[];
|
|
170
|
+
pointerType: PointerType;
|
|
168
171
|
};
|
|
169
172
|
|
|
170
173
|
export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =
|