react-native-gesture-handler 2.24.0 → 2.25.0
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 +3 -0
- package/android/build.gradle +39 -12
- package/android/fabric/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +2 -0
- package/android/nosvg/src/main/java/com/swmansion/gesturehandler/RNSVGHitTester.kt +13 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +6 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +13 -3
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +8 -2
- package/android/svg/src/main/java/com/swmansion/gesturehandler/RNSVGHitTester.kt +67 -0
- package/apple/RNGestureHandlerButtonComponentView.h +2 -1
- package/apple/RNGestureHandlerButtonComponentView.mm +95 -0
- package/lib/commonjs/components/GestureButtons.js +5 -4
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +76 -40
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +5 -8
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js +12 -5
- package/lib/commonjs/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +3 -7
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +0 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/InteractionManager.js +1 -3
- package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
- package/lib/module/components/GestureButtons.js +4 -3
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +75 -39
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/handlers/createHandler.js +5 -8
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js +12 -5
- package/lib/module/handlers/gestures/GestureDetector/updateHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +3 -6
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +0 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/InteractionManager.js +1 -2
- package/lib/module/web/tools/InteractionManager.js.map +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +3 -3
- package/lib/typescript/components/Pressable/Pressable.d.ts +3 -1
- package/package.json +4 -2
- package/src/components/GestureButtons.tsx +13 -9
- package/src/components/Pressable/Pressable.tsx +400 -351
- package/src/handlers/createHandler.tsx +4 -8
- package/src/handlers/gestures/GestureDetector/updateHandlers.ts +11 -3
- package/src/handlers/gestures/GestureDetector/utils.ts +3 -7
- package/src/web/tools/GestureHandlerOrchestrator.ts +0 -1
- package/src/web/tools/InteractionManager.ts +1 -2
- package/lib/commonjs/getReactNativeVersion.js +0 -22
- package/lib/commonjs/getReactNativeVersion.js.map +0 -1
- package/lib/commonjs/getReactNativeVersion.web.js +0 -11
- package/lib/commonjs/getReactNativeVersion.web.js.map +0 -1
- package/lib/module/getReactNativeVersion.js +0 -10
- package/lib/module/getReactNativeVersion.js.map +0 -1
- package/lib/module/getReactNativeVersion.web.js +0 -4
- package/lib/module/getReactNativeVersion.web.js.map +0 -1
- package/lib/typescript/getReactNativeVersion.d.ts +0 -4
- package/lib/typescript/getReactNativeVersion.web.d.ts +0 -1
- package/src/getReactNativeVersion.ts +0 -11
- package/src/getReactNativeVersion.web.ts +0 -3
@@ -77,12 +77,8 @@ UIManagerAny.genericDirectEventTypes = {
|
|
77
77
|
...UIManagerAny.genericDirectEventTypes,
|
78
78
|
...customGHEventsConfig,
|
79
79
|
};
|
80
|
-
|
81
|
-
|
82
|
-
// it compatible with RN 61+
|
83
|
-
const UIManagerConstants =
|
84
|
-
UIManagerAny.getViewManagerConfig?.('getConstants') ??
|
85
|
-
UIManagerAny.getConstants?.();
|
80
|
+
|
81
|
+
const UIManagerConstants = UIManagerAny.getViewManagerConfig?.('getConstants');
|
86
82
|
|
87
83
|
if (UIManagerConstants) {
|
88
84
|
UIManagerConstants.genericDirectEventTypes = {
|
@@ -190,7 +186,7 @@ export default function createHandler<
|
|
190
186
|
static displayName = name;
|
191
187
|
static contextType = GestureHandlerRootViewContext;
|
192
188
|
|
193
|
-
private handlerTag
|
189
|
+
private handlerTag = -1;
|
194
190
|
private config: Record<string, unknown>;
|
195
191
|
private propsRef: React.MutableRefObject<unknown>;
|
196
192
|
private isMountedRef: React.MutableRefObject<boolean | null>;
|
@@ -200,7 +196,6 @@ export default function createHandler<
|
|
200
196
|
|
201
197
|
constructor(props: T & InternalEventHandlers) {
|
202
198
|
super(props);
|
203
|
-
this.handlerTag = getNextHandlerTag();
|
204
199
|
this.config = {};
|
205
200
|
this.propsRef = React.createRef();
|
206
201
|
this.isMountedRef = React.createRef();
|
@@ -333,6 +328,7 @@ export default function createHandler<
|
|
333
328
|
private createGestureHandler = (
|
334
329
|
newConfig: Readonly<Record<string, unknown>>
|
335
330
|
) => {
|
331
|
+
this.handlerTag = getNextHandlerTag();
|
336
332
|
this.config = newConfig;
|
337
333
|
|
338
334
|
RNGestureHandlerModule.createGestureHandler(
|
@@ -30,6 +30,9 @@ export function updateHandlers(
|
|
30
30
|
}
|
31
31
|
}
|
32
32
|
|
33
|
+
// Store attached gestures to avoid crash when gestures changed after queueing micro task
|
34
|
+
const attachedGestures = preparedGesture.attachedGestures;
|
35
|
+
|
33
36
|
// Use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
|
34
37
|
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
|
35
38
|
// in case of external relations)
|
@@ -38,12 +41,17 @@ export function updateHandlers(
|
|
38
41
|
return;
|
39
42
|
}
|
40
43
|
|
44
|
+
// Stop if attached gestures changed after queueing micro task
|
45
|
+
if (attachedGestures !== preparedGesture.attachedGestures) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
|
41
49
|
// If amount of gesture configs changes, we need to update the callbacks in shared value
|
42
50
|
let shouldUpdateSharedValueIfUsed =
|
43
|
-
|
51
|
+
attachedGestures.length !== newGestures.length;
|
44
52
|
|
45
53
|
for (let i = 0; i < newGestures.length; i++) {
|
46
|
-
const handler =
|
54
|
+
const handler = attachedGestures[i];
|
47
55
|
|
48
56
|
// If the gestureId is different (gesture isn't wrapped with useMemo or its dependencies changed),
|
49
57
|
// we need to update the shared value, assuming the gesture runs on UI thread or the thread changed
|
@@ -70,7 +78,7 @@ export function updateHandlers(
|
|
70
78
|
}
|
71
79
|
|
72
80
|
if (preparedGesture.animatedHandlers && shouldUpdateSharedValueIfUsed) {
|
73
|
-
const newHandlersValue =
|
81
|
+
const newHandlersValue = attachedGestures
|
74
82
|
.filter((g) => g.shouldUseReanimated) // Ignore gestures that shouldn't run on UI
|
75
83
|
.map((g) => g.handlers) as unknown as HandlerCallbacks<
|
76
84
|
Record<string, unknown>
|
@@ -18,7 +18,6 @@ import {
|
|
18
18
|
baseGestureHandlerWithDetectorProps,
|
19
19
|
} from '../../gestureHandlerCommon';
|
20
20
|
import { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';
|
21
|
-
import { getReactNativeVersion } from '../../../getReactNativeVersion';
|
22
21
|
import { RNRenderer } from '../../../RNRenderer';
|
23
22
|
import { useCallback, useRef, useState } from 'react';
|
24
23
|
import { Reanimated } from '../reanimatedWrapper';
|
@@ -133,14 +132,11 @@ export function validateDetectorChildren(ref: any) {
|
|
133
132
|
// / \
|
134
133
|
// NativeView NativeView
|
135
134
|
if (__DEV__ && Platform.OS !== 'web') {
|
136
|
-
const REACT_NATIVE_VERSION = getReactNativeVersion();
|
137
135
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
138
136
|
const wrapType =
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
: // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
143
|
-
ref._reactInternalFiber.elementType;
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
138
|
+
ref._reactInternals.elementType;
|
139
|
+
|
144
140
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
145
141
|
let instance =
|
146
142
|
RNRenderer.findHostInstance_DEPRECATED(
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import type IGestureHandler from '../handlers/IGestureHandler';
|
2
|
-
import { State } from '../../State';
|
3
2
|
import { Config, Handler } from '../interfaces';
|
4
3
|
|
5
4
|
export default class InteractionManager {
|
@@ -108,7 +107,7 @@ export default class InteractionManager {
|
|
108
107
|
// We check constructor name instead of using `instanceof` in order do avoid circular dependencies
|
109
108
|
const isNativeHandler =
|
110
109
|
otherHandler.constructor.name === 'NativeViewGestureHandler';
|
111
|
-
const isActive = otherHandler.
|
110
|
+
const isActive = otherHandler.active;
|
112
111
|
const isButton = otherHandler.isButton?.() === true;
|
113
112
|
|
114
113
|
return isNativeHandler && isActive && !isButton;
|
@@ -1,22 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.getReactNativeVersion = getReactNativeVersion;
|
7
|
-
|
8
|
-
var _package = _interopRequireDefault(require("react-native/package.json"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
|
12
|
-
const [majorStr, minorStr] = _package.default.version.split('.');
|
13
|
-
|
14
|
-
const REACT_NATIVE_VERSION = {
|
15
|
-
major: parseInt(majorStr, 10),
|
16
|
-
minor: parseInt(minorStr, 10)
|
17
|
-
};
|
18
|
-
|
19
|
-
function getReactNativeVersion() {
|
20
|
-
return REACT_NATIVE_VERSION;
|
21
|
-
}
|
22
|
-
//# sourceMappingURL=getReactNativeVersion.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getReactNativeVersion.ts"],"names":["majorStr","minorStr","pack","version","split","REACT_NATIVE_VERSION","major","parseInt","minor","getReactNativeVersion"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAM,CAACA,QAAD,EAAWC,QAAX,IAAuBC,iBAAKC,OAAL,CAAaC,KAAb,CAAmB,GAAnB,CAA7B;;AACA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,KAAK,EAAEC,QAAQ,CAACP,QAAD,EAAW,EAAX,CADY;AAE3BQ,EAAAA,KAAK,EAAED,QAAQ,CAACN,QAAD,EAAW,EAAX;AAFY,CAA7B;;AAKO,SAASQ,qBAAT,GAAiC;AACtC,SAAOJ,oBAAP;AACD","sourcesContent":["import pack from 'react-native/package.json';\n\nconst [majorStr, minorStr] = pack.version.split('.');\nconst REACT_NATIVE_VERSION = {\n major: parseInt(majorStr, 10),\n minor: parseInt(minorStr, 10),\n};\n\nexport function getReactNativeVersion() {\n return REACT_NATIVE_VERSION;\n}\n"]}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.getReactNativeVersion = getReactNativeVersion;
|
7
|
-
|
8
|
-
function getReactNativeVersion() {
|
9
|
-
throw new Error('getReactNativeVersion is not supported on web');
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=getReactNativeVersion.web.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getReactNativeVersion.web.ts"],"names":["getReactNativeVersion","Error"],"mappings":";;;;;;;AAAO,SAASA,qBAAT,GAAiC;AACtC,QAAM,IAAIC,KAAJ,CAAU,+CAAV,CAAN;AACD","sourcesContent":["export function getReactNativeVersion() {\n throw new Error('getReactNativeVersion is not supported on web');\n}\n"]}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import pack from 'react-native/package.json';
|
2
|
-
const [majorStr, minorStr] = pack.version.split('.');
|
3
|
-
const REACT_NATIVE_VERSION = {
|
4
|
-
major: parseInt(majorStr, 10),
|
5
|
-
minor: parseInt(minorStr, 10)
|
6
|
-
};
|
7
|
-
export function getReactNativeVersion() {
|
8
|
-
return REACT_NATIVE_VERSION;
|
9
|
-
}
|
10
|
-
//# sourceMappingURL=getReactNativeVersion.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getReactNativeVersion.ts"],"names":["pack","majorStr","minorStr","version","split","REACT_NATIVE_VERSION","major","parseInt","minor","getReactNativeVersion"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,2BAAjB;AAEA,MAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBF,IAAI,CAACG,OAAL,CAAaC,KAAb,CAAmB,GAAnB,CAA7B;AACA,MAAMC,oBAAoB,GAAG;AAC3BC,EAAAA,KAAK,EAAEC,QAAQ,CAACN,QAAD,EAAW,EAAX,CADY;AAE3BO,EAAAA,KAAK,EAAED,QAAQ,CAACL,QAAD,EAAW,EAAX;AAFY,CAA7B;AAKA,OAAO,SAASO,qBAAT,GAAiC;AACtC,SAAOJ,oBAAP;AACD","sourcesContent":["import pack from 'react-native/package.json';\n\nconst [majorStr, minorStr] = pack.version.split('.');\nconst REACT_NATIVE_VERSION = {\n major: parseInt(majorStr, 10),\n minor: parseInt(minorStr, 10),\n};\n\nexport function getReactNativeVersion() {\n return REACT_NATIVE_VERSION;\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["getReactNativeVersion.web.ts"],"names":["getReactNativeVersion","Error"],"mappings":"AAAA,OAAO,SAASA,qBAAT,GAAiC;AACtC,QAAM,IAAIC,KAAJ,CAAU,+CAAV,CAAN;AACD","sourcesContent":["export function getReactNativeVersion() {\n throw new Error('getReactNativeVersion is not supported on web');\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare function getReactNativeVersion(): void;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import pack from 'react-native/package.json';
|
2
|
-
|
3
|
-
const [majorStr, minorStr] = pack.version.split('.');
|
4
|
-
const REACT_NATIVE_VERSION = {
|
5
|
-
major: parseInt(majorStr, 10),
|
6
|
-
minor: parseInt(minorStr, 10),
|
7
|
-
};
|
8
|
-
|
9
|
-
export function getReactNativeVersion() {
|
10
|
-
return REACT_NATIVE_VERSION;
|
11
|
-
}
|