Skip to content

Commit e26bc01

Browse files
authored
Rename relation props in config (#3817)
## Description Renames the configuration fields used for gesture relations: - `simultaneousWithExternalGesture` -> `simultaneousWith` - `requireExternalGestureToFail` -> `requireToFail` - `blocksExternalGesture` -> `block` I'm not entirely sold on `block`, I'd love to hear opinions. ## Test plan Static checks
1 parent dfff6e9 commit e26bc01

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,20 @@ describe('Simple relations', () => {
102102
});
103103

104104
describe('External relations', () => {
105-
test('simultaneousWithExternalGesture', () => {
105+
test('simultaneousWith', () => {
106106
const pan1 = renderHook(() =>
107107
useGesture(SingleGestureName.Pan, { disableReanimated: true })
108108
).result.current;
109109
const pan2 = renderHook(() =>
110110
useGesture(SingleGestureName.Pan, {
111111
disableReanimated: true,
112-
simultaneousWithExternalGesture: pan1,
112+
simultaneousWith: pan1,
113113
})
114114
).result.current;
115115
const pan3 = renderHook(() =>
116116
useGesture(SingleGestureName.Pan, {
117117
disableReanimated: true,
118-
simultaneousWithExternalGesture: [pan1, pan2],
118+
simultaneousWith: [pan1, pan2],
119119
})
120120
).result.current;
121121

@@ -134,20 +134,20 @@ describe('External relations', () => {
134134
);
135135
});
136136

137-
test('requireExternalGestureToFail', () => {
137+
test('requireToFail', () => {
138138
const pan1 = renderHook(() =>
139139
useGesture(SingleGestureName.Pan, { disableReanimated: true })
140140
).result.current;
141141
const pan2 = renderHook(() =>
142142
useGesture(SingleGestureName.Pan, {
143143
disableReanimated: true,
144-
requireExternalGestureToFail: pan1,
144+
requireToFail: pan1,
145145
})
146146
).result.current;
147147
const pan3 = renderHook(() =>
148148
useGesture(SingleGestureName.Pan, {
149149
disableReanimated: true,
150-
requireExternalGestureToFail: [pan1, pan2],
150+
requireToFail: [pan1, pan2],
151151
})
152152
).result.current;
153153

@@ -160,20 +160,20 @@ describe('External relations', () => {
160160
expect(pan3.gestureRelations.waitFor).toStrictEqual([pan1.tag, pan2.tag]);
161161
});
162162

163-
test('blocksExternalGesture', () => {
163+
test('blocks', () => {
164164
const pan1 = renderHook(() =>
165165
useGesture(SingleGestureName.Pan, { disableReanimated: true })
166166
).result.current;
167167
const pan2 = renderHook(() =>
168168
useGesture(SingleGestureName.Pan, {
169169
disableReanimated: true,
170-
blocksExternalGesture: pan1,
170+
block: pan1,
171171
})
172172
).result.current;
173173
const pan3 = renderHook(() =>
174174
useGesture(SingleGestureName.Pan, {
175175
disableReanimated: true,
176-
blocksExternalGesture: [pan1, pan2],
176+
block: [pan1, pan2],
177177
})
178178
).result.current;
179179

@@ -313,25 +313,25 @@ describe('Complex relations with external gestures', () => {
313313
const pan1 = renderHook(() =>
314314
useGesture(SingleGestureName.Pan, {
315315
disableReanimated: true,
316-
simultaneousWithExternalGesture: pan5,
316+
simultaneousWith: pan5,
317317
})
318318
).result.current;
319319
const pan2 = renderHook(() =>
320320
useGesture(SingleGestureName.Pan, {
321321
disableReanimated: true,
322-
simultaneousWithExternalGesture: pan5,
322+
simultaneousWith: pan5,
323323
})
324324
).result.current;
325325
const pan3 = renderHook(() =>
326326
useGesture(SingleGestureName.Pan, {
327327
disableReanimated: true,
328-
requireExternalGestureToFail: pan5,
328+
requireToFail: pan5,
329329
})
330330
).result.current;
331331
const pan4 = renderHook(() =>
332332
useGesture(SingleGestureName.Pan, {
333333
disableReanimated: true,
334-
requireExternalGestureToFail: pan5,
334+
requireToFail: pan5,
335335
})
336336
).result.current;
337337

@@ -391,14 +391,14 @@ describe('Complex relations with external gestures', () => {
391391
const pan1 = renderHook(() =>
392392
useGesture(SingleGestureName.Pan, {
393393
disableReanimated: true,
394-
simultaneousWithExternalGesture: [pan4, pan5],
394+
simultaneousWith: [pan4, pan5],
395395
})
396396
).result.current;
397397

398398
const pan2 = renderHook(() =>
399399
useGesture(SingleGestureName.Pan, {
400400
disableReanimated: true,
401-
requireExternalGestureToFail: [pan4, pan5],
401+
requireToFail: [pan4, pan5],
402402
})
403403
).result.current;
404404

@@ -466,7 +466,7 @@ describe('External relations with composed gestures', () => {
466466
const pan3 = renderHook(() =>
467467
useGesture(SingleGestureName.Pan, {
468468
disableReanimated: true,
469-
simultaneousWithExternalGesture: composedGesture,
469+
simultaneousWith: composedGesture,
470470
})
471471
).result.current;
472472

@@ -503,7 +503,7 @@ describe('External relations with composed gestures', () => {
503503
const pan3 = renderHook(() =>
504504
useGesture(SingleGestureName.Pan, {
505505
disableReanimated: true,
506-
simultaneousWithExternalGesture: composedGesture,
506+
simultaneousWith: composedGesture,
507507
})
508508
).result.current;
509509

packages/react-native-gesture-handler/src/v3/hooks/utils/relationUtils.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function extractHandlerTags(
3333
return otherTags;
3434
}
3535

36-
function makeSimultaneousWithExternalGestureSymmetric(
36+
function makeSimultaneousWithSymmetric(
3737
otherHandler: Gesture | Gesture[] | undefined,
3838
handlerTag: number
3939
) {
@@ -62,17 +62,12 @@ export function prepareRelations<THandlerData, TConfig>(
6262
config: BaseGestureConfig<THandlerData, TConfig>,
6363
handlerTag: number
6464
): GestureRelations {
65-
makeSimultaneousWithExternalGestureSymmetric(
66-
config.simultaneousWithExternalGesture,
67-
handlerTag
68-
);
65+
makeSimultaneousWithSymmetric(config.simultaneousWith, handlerTag);
6966

7067
return {
71-
simultaneousHandlers: extractHandlerTags(
72-
config.simultaneousWithExternalGesture
73-
),
74-
waitFor: extractHandlerTags(config.requireExternalGestureToFail),
75-
blocksHandlers: extractHandlerTags(config.blocksExternalGesture),
68+
simultaneousHandlers: extractHandlerTags(config.simultaneousWith),
69+
waitFor: extractHandlerTags(config.requireToFail),
70+
blocksHandlers: extractHandlerTags(config.block),
7671
};
7772
}
7873

packages/react-native-gesture-handler/src/v3/types/GestureTypes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { FilterNeverProperties } from './UtilityTypes';
1010

1111
// Unfortunately, this type cannot be moved into ConfigTypes.ts because of circular dependency
1212
type ExternalRelations = {
13-
simultaneousWithExternalGesture?: Gesture | Gesture[];
14-
requireExternalGestureToFail?: Gesture | Gesture[];
15-
blocksExternalGesture?: Gesture | Gesture[];
13+
simultaneousWith?: Gesture | Gesture[];
14+
requireToFail?: Gesture | Gesture[];
15+
block?: Gesture | Gesture[];
1616
};
1717

1818
// Similarly, this type cannot be moved into ConfigTypes.ts because it depends on `ExternalRelations`

0 commit comments

Comments
 (0)