Skip to content

Commit 21462d8

Browse files
committed
Merge branch 'main' into @mbert/support-81
2 parents 6ec0a00 + 2d19b81 commit 21462d8

18 files changed

Lines changed: 132 additions & 113 deletions

File tree

apps/basic-example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ PODS:
22232223
- React-perflogger (= 0.81.0-rc.1)
22242224
- React-utils (= 0.81.0-rc.1)
22252225
- SocketRocket
2226-
- RNGestureHandler (2.27.1):
2226+
- RNGestureHandler (2.27.2):
22272227
- boost
22282228
- DoubleConversion
22292229
- fast_float
@@ -2552,7 +2552,7 @@ SPEC CHECKSUMS:
25522552
ReactAppDependencyProvider: d6047f02061d1d4ddea220c25c03dc0f85fa3e66
25532553
ReactCodegen: 0949385fa4cc4ad03dc5bfe516db5d256bfa1503
25542554
ReactCommon: 9c0b5f78d34ee283d93cfd59fe0271ba629b2045
2555-
RNGestureHandler: e8dd08066308e649ff7f13ed7d4e3dc8faae7fc5
2555+
RNGestureHandler: 0fbc8afacdf8e7fcd4dc5cc1773bfb9cb4f710e8
25562556
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
25572557
Yoga: 865fbf57ad8aa871fbe40f8cd286825fad7cf80f
25582558

apps/expo-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"main": "index.ts",
55
"scripts": {
66
"postinstall": "npx expo prebuild",
7-
"start": "expo start",
7+
"start": "expo start --dev-client",
88
"android": "expo run:android",
99
"ios": "expo run:ios",
1010
"web": "expo start --web",

apps/macos-example/macos/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ PODS:
14841484
- React-utils (= 0.78.3)
14851485
- RNCAsyncStorage (2.1.2):
14861486
- React-Core
1487-
- RNGestureHandler (2.27.1):
1487+
- RNGestureHandler (2.27.2):
14881488
- DoubleConversion
14891489
- glog
14901490
- RCT-Folly (= 2024.11.18.00)
@@ -1854,8 +1854,8 @@ SPEC CHECKSUMS:
18541854
React-debug: 9ef45d64b88281e7e629158410ceb61b3bb51ea0
18551855
React-defaultsnativemodule: 4e5646f85edca54998efb35efac242045d1123dc
18561856
React-domnativemodule: aa0750129c97675305ad52da5e0525985a7bc1c9
1857-
React-Fabric: e5670d9e6c90650fc3d8b86eedfb3a75b80152cb
1858-
React-FabricComponents: d1e9208aa6b2134bb1c18d8a42cf4c975ffc755d
1857+
React-Fabric: 20a409df4dc64d8139324f707837bfa72d5663ce
1858+
React-FabricComponents: a8ad8665dacbf82a4669f5a4e55531594c65601b
18591859
React-FabricImage: 309d4ebb53631461fc8108b7b3ce6dc84f135a20
18601860
React-featureflags: 46790800dbdeb1305b3b12427b4d18413dadd13e
18611861
React-featureflagsnativemodule: eb77d500c3770978e9c1c8e6f3f36a923ca7eecf
@@ -1901,12 +1901,12 @@ SPEC CHECKSUMS:
19011901
ReactCodegen: 3d30536e47f328f0a297d897cb789e46a092c2a6
19021902
ReactCommon: 0f22e3dd34a8215b8482778898f6e1e95572c498
19031903
RNCAsyncStorage: b9f5f78da5d16a853fe3dc22e8268d932fc45a83
1904-
RNGestureHandler: 231e0ff647e2f3b6a26b86f0fb1978b22cdbd1c6
1904+
RNGestureHandler: 9ea0b24ab06251465e366792c8d1a8f96d7a41ad
19051905
RNReanimated: 6ccc6e6826ada6643d2e6474d95f37a1fbf7771d
19061906
RNSVG: 4c63b12b7b5761063bca4f20dd228f6a8370f614
19071907
SocketRocket: 03f7111df1a343b162bf5b06ead333be808e1e0a
19081908
Yoga: f89a870053f1a8fbee8c98e35a1b9eff44ce2015
19091909

19101910
PODFILE CHECKSUM: ba6f2105d3e43bf0ae77356a9afcc8b532e3c306
19111911

1912-
COCOAPODS: 1.16.2
1912+
COCOAPODS: 1.15.2

packages/docs-gesture-handler/docs/gestures/pinch-gesture.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ const styles = StyleSheet.create({
9393
});
9494
```
9595

96+
## Remarks
97+
98+
- When implementing pinch based on `focal` point, make sure to use it after gesture has activated, i.e. in `onStart`, `onUpdate` or `onChange` callbacks. Using it in `onBegan` may lead to unexpected behavior.
99+
96100
## Config
97101

98102
<BaseEventConfig />

packages/docs-gesture-handler/docs/gestures/rotation-gesture.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ const styles = StyleSheet.create({
9090
});
9191
```
9292

93+
## Remarks
94+
95+
- When implementing rotation based on `anchor` point, make sure to use it after gesture has activated, i.e. in `onStart`, `onUpdate` or `onChange` callbacks. Using it in `onBegan` may lead to unexpected behavior.
96+
9397
## Config
9498

9599
<BaseEventConfig />
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
jest.mock('./src/RNGestureHandlerModule', () => require('./src/mocks'));
1+
jest.mock('./src/RNGestureHandlerModule', () => require('./src/mocks/mocks'));
2+
jest.mock('./src/components/GestureButtons', () => require('./src/mocks/mocks'));
3+
jest.mock('./src/components/Pressable/Pressable', () => require('./src/mocks/Pressable'));
4+
5+
26
jest.mock('./lib/commonjs/RNGestureHandlerModule', () =>
3-
require('./lib/commonjs/mocks')
7+
require('./lib/commonjs/mocks/mocks')
48
);
9+
jest.mock('./lib/commonjs/components/GestureButtons', () =>
10+
require('./lib/commonjs/mocks/mocks')
11+
);
12+
jest.mock('./lib/commonjs/components/Pressable', () =>
13+
require('./lib/commonjs/mocks/Pressable')
14+
);
15+
16+
517
jest.mock('./lib/module/RNGestureHandlerModule', () =>
6-
require('./lib/module/mocks')
18+
require('./lib/module/mocks/mocks')
19+
);
20+
jest.mock('./lib/module/components/GestureButtons', () =>
21+
require('./lib/module/mocks/mocks')
22+
);
23+
jest.mock('./lib/module/components/Pressable', () =>
24+
require('./lib/module/mocks/Pressable')
725
);
26+

packages/react-native-gesture-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-gesture-handler",
3-
"version": "2.27.1",
3+
"version": "2.27.2",
44
"description": "Declarative API exposing native platform touch and gesture system to React Native",
55
"scripts": {
66
"test": "jest",

packages/react-native-gesture-handler/src/__mocks__/RNGestureHandlerModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Mocks from '../mocks';
1+
import Mocks from '../mocks/mocks';
22

33
export default {
44
...Mocks,

packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import {
33
AccessibilityProps,
44
ColorValue,
5+
LayoutChangeEvent,
56
StyleProp,
67
ViewStyle,
78
} from 'react-native';
@@ -56,26 +57,35 @@ export interface RawButtonProps
5657
*/
5758
style?: StyleProp<ViewStyle>;
5859

60+
/**
61+
* Invoked on mount and layout changes.
62+
*/
63+
onLayout?: (event: LayoutChangeEvent) => void;
64+
5965
/**
6066
* Used for testing-library compatibility, not passed to the native component.
67+
* @deprecated test-only props are deprecated and will be removed in the future.
6168
*/
6269
// eslint-disable-next-line @typescript-eslint/ban-types
6370
testOnly_onPress?: Function | null;
6471

6572
/**
6673
* Used for testing-library compatibility, not passed to the native component.
74+
* @deprecated test-only props are deprecated and will be removed in the future.
6775
*/
6876
// eslint-disable-next-line @typescript-eslint/ban-types
6977
testOnly_onPressIn?: Function | null;
7078

7179
/**
7280
* Used for testing-library compatibility, not passed to the native component.
81+
* @deprecated test-only props are deprecated and will be removed in the future.
7382
*/
7483
// eslint-disable-next-line @typescript-eslint/ban-types
7584
testOnly_onPressOut?: Function | null;
7685

7786
/**
7887
* Used for testing-library compatibility, not passed to the native component.
88+
* @deprecated test-only props are deprecated and will be removed in the future.
7989
*/
8090
// eslint-disable-next-line @typescript-eslint/ban-types
8191
testOnly_onLongPress?: Function | null;

packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, {
22
useCallback,
33
useEffect,
4-
useLayoutEffect,
54
useMemo,
65
useRef,
76
useState,
@@ -15,9 +14,9 @@ import {
1514
} from './PressableProps';
1615
import {
1716
Insets,
17+
LayoutChangeEvent,
1818
Platform,
1919
StyleProp,
20-
View,
2120
ViewStyle,
2221
processColor,
2322
} from 'react-native';
@@ -46,7 +45,6 @@ let IS_FABRIC: null | boolean = null;
4645

4746
const Pressable = (props: PressableProps) => {
4847
const {
49-
ref,
5048
testOnly_pressed,
5149
hitSlop,
5250
pressRetentionOffset,
@@ -60,6 +58,7 @@ const Pressable = (props: PressableProps) => {
6058
onPressIn,
6159
onPressOut,
6260
onLongPress,
61+
onLayout,
6362
style,
6463
children,
6564
android_disableSound,
@@ -69,7 +68,6 @@ const Pressable = (props: PressableProps) => {
6968
simultaneousWithExternalGesture,
7069
requireExternalGestureToFail,
7170
blocksExternalGesture,
72-
dimensionsAfterResize,
7371
...remainingProps
7472
} = props;
7573

@@ -79,9 +77,6 @@ const Pressable = (props: PressableProps) => {
7977
blocksExternalGesture,
8078
};
8179

82-
// used only if `ref` is undefined
83-
const fallbackRef = useRef<View>(null);
84-
8580
const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);
8681

8782
const longPressTimeoutRef = useRef<number | null>(null);
@@ -109,21 +104,6 @@ const Pressable = (props: PressableProps) => {
109104
normalizedPressRetentionOffset
110105
);
111106

112-
useLayoutEffect(() => {
113-
if (dimensionsAfterResize) {
114-
dimensions.current = dimensionsAfterResize;
115-
} else {
116-
requestAnimationFrame(() => {
117-
(ref ?? fallbackRef).current?.measure((_x, _y, width, height) => {
118-
dimensions.current = {
119-
width,
120-
height,
121-
};
122-
});
123-
});
124-
}
125-
}, [dimensionsAfterResize, ref]);
126-
127107
const cancelLongPress = useCallback(() => {
128108
if (longPressTimeoutRef.current) {
129109
clearTimeout(longPressTimeoutRef.current);
@@ -377,11 +357,19 @@ const Pressable = (props: PressableProps) => {
377357
: processColor(unprocessedRippleColor);
378358
}, [android_ripple]);
379359

360+
const setDimensions = useCallback(
361+
(event: LayoutChangeEvent) => {
362+
onLayout?.(event);
363+
dimensions.current = event.nativeEvent.layout;
364+
},
365+
[onLayout]
366+
);
367+
380368
return (
381369
<GestureDetector gesture={gesture}>
382370
<NativeButton
383371
{...remainingProps}
384-
ref={ref ?? fallbackRef}
372+
onLayout={setDimensions}
385373
accessible={accessible !== false}
386374
hitSlop={appliedHitSlop}
387375
enabled={isPressableEnabled}

0 commit comments

Comments
 (0)