Skip to content

Commit ab44f1e

Browse files
authored
[Web] Align Tap maxDelay default with native (200 ms) (#4557)
## Description The default for Tap's `maxDelay` (how long the handler waits for the next tap when `numberOfTaps > 1`) was 500 ms on web but 200 ms on Android and Apple, so the same `useTapGesture({ numberOfTaps: 2 })` behaved differently per platform: | Platform | Default | Location | |---|---|---| | Web | 500 ms | `src/web/handlers/TapGestureHandler.ts:10` | | Android | 200 ms | `android/.../core/TapGestureHandler.kt:190` | | Apple | 200 ms | `apple/Handlers/RNTapHandler.m:51` | As discussed in #4555, 200 ms is the intended default, since it is the value chosen for mobile. This PR changes web to 200 ms and updates the places that stated 500 ms: the `useTapGesture` docs page and the `maxDelay` comments in `TapTypes.ts`, the v1 `TapGestureHandler.ts` and the v2 `tapGesture.ts`. The 1.x and 2.x versioned docs are untouched. **Behaviour change:** on web, a multi-tap now fails if the next tap takes longer than 200 ms, unless `maxDelay` is set explicitly. Setting it keeps working as before. Discussion: #4555 ## Test plan Ran in `packages/react-native-gesture-handler`: - `yarn test`: 21 suites, 178 tests passed - `yarn ts-check`: exit 0 - `yarn lint:js`: exit 0, 0 errors I also checked the new default with a throwaway Jest test (two-tap config, first tap, 300 ms passes), which failed at 500 and passed at 200. It is not included in the PR. The change is web and docs only, so I did not run Android or iOS builds.
1 parent bb62b06 commit ab44f1e

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎packages/docs-gesture-handler/docs/gestures/use-tap-gesture.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Maximum time, expressed in milliseconds, that defines how fast a finger must be
109109
maxDelay: number | SharedValue<number>;
110110
```
111111

112-
Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required. The default value is 500.
112+
Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required. The default value is 200.
113113

114114
### numberOfTaps
115115

‎packages/react-native-gesture-handler/src/handlers/TapGestureHandler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface TapGestureConfig {
2929

3030
/**
3131
* Maximum time, expressed in milliseconds, that can pass before the next tap
32-
* if many taps are required. The default value is 500.
32+
* if many taps are required. The default value is 200.
3333
*/
3434
maxDelayMs?: number;
3535

‎packages/react-native-gesture-handler/src/handlers/gestures/tapGesture.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class TapGesture extends BaseGesture<TapGestureHandlerEventPayload> {
5858

5959
/**
6060
* Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required.
61-
* The default value is 500.
61+
* The default value is 200.
6262
* @param delay
6363
*/
6464
maxDelay(delay: number) {

‎packages/react-native-gesture-handler/src/v3/hooks/gestures/tap/TapTypes.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type TapGestureExternalConfig = CommonTapGestureConfig & {
4646

4747
/**
4848
* Maximum time, expressed in milliseconds, that can pass before the next tap
49-
* if many taps are required. The default value is 500.
49+
* if many taps are required. The default value is 200.
5050
*/
5151
maxDelay?: number;
5252

‎packages/react-native-gesture-handler/src/web/handlers/TapGestureHandler.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import GestureHandler from './GestureHandler';
77
import type IGestureHandler from './IGestureHandler';
88

99
const DEFAULT_MAX_DURATION_MS = 500;
10-
const DEFAULT_MAX_DELAY_MS = 500;
10+
const DEFAULT_MAX_DELAY_MS = 200;
1111
const DEFAULT_NUMBER_OF_TAPS = 1;
1212
const DEFAULT_MIN_NUMBER_OF_POINTERS = 1;
1313

0 commit comments

Comments
 (0)