Commit 4363f48
authored
[Native] Add
## Description
Based on react/react-native#57259, adds a new
`delaysChildPressedState` config entry to the native gesture handler and
exposes it on the `ScrollView`.
The default behavior remains unchanged (visual feedback is delayed in
scrollable containers), but can be disabled using the new config entry.
Since `HasChildPressedStateDelay` interface is available starting with
React Native 0.87, it's currently accessed using reflection to keep
backwards compatibility. On older versions, `delaysChildPressedState` is
a no-op. Once 0.87 is the lowest compatible version with RNGH, we can
drop the reflection and use it directly.
## Test plan
```jsx
import * as React from 'react';
import { Platform, SafeAreaView } from 'react-native';
import {
GestureHandlerRootView,
ScrollView,
Touchable,
} from 'react-native-gesture-handler';
export default function App() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<SafeAreaView
style={[
{ flex: 1, flexDirection: 'row' },
Platform.OS === 'android' && { paddingTop: 50 },
]}>
<ScrollView
delaysChildPressedState={false}
style={{ width: '50%', height: 200, backgroundColor: 'lightgray' }}>
<Touchable
style={{ width: 100, height: 100, backgroundColor: 'red' }}
activeScale={0.9}
onPress={() => console.log('Pressed!')}
/>
</ScrollView>
<ScrollView
delaysChildPressedState={true}
style={{ width: '50%', height: 200, backgroundColor: 'lightgray' }}>
<Touchable
style={{ width: 100, height: 100, backgroundColor: 'red' }}
activeScale={0.9}
onPress={() => console.log('Pressed!')}
/>
</ScrollView>
</SafeAreaView>
</GestureHandlerRootView>
);
}
```delaysChildPressedState to native gesture (#4308)1 parent 201493f commit 4363f48
4 files changed
Lines changed: 99 additions & 2 deletions
File tree
- packages
- docs-gesture-handler/docs/gestures
- react-native-gesture-handler
- android/src/main/java/com/swmansion/gesturehandler/core
- apple/Handlers
- src/v3/hooks/gestures/native
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
126 | 138 | | |
127 | 139 | | |
128 | 140 | | |
| |||
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
| |||
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
| 68 | + | |
56 | 69 | | |
57 | 70 | | |
58 | 71 | | |
| |||
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
118 | 139 | | |
119 | 140 | | |
120 | 141 | | |
| |||
179 | 200 | | |
180 | 201 | | |
181 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
182 | 206 | | |
183 | 207 | | |
184 | 208 | | |
| |||
214 | 238 | | |
215 | 239 | | |
216 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
217 | 244 | | |
218 | 245 | | |
219 | 246 | | |
| |||
222 | 249 | | |
223 | 250 | | |
224 | 251 | | |
| 252 | + | |
225 | 253 | | |
226 | 254 | | |
227 | 255 | | |
| |||
230 | 258 | | |
231 | 259 | | |
232 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
233 | 288 | | |
234 | 289 | | |
235 | 290 | | |
| |||
Lines changed: 16 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
134 | 147 | | |
135 | 148 | | |
136 | 149 | | |
| |||
177 | 190 | | |
178 | 191 | | |
179 | 192 | | |
180 | | - | |
| 193 | + | |
| 194 | + | |
181 | 195 | | |
182 | | - | |
| 196 | + | |
183 | 197 | | |
184 | 198 | | |
185 | 199 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
31 | 46 | | |
32 | 47 | | |
33 | 48 | | |
| |||
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| 54 | + | |
39 | 55 | | |
40 | 56 | | |
41 | 57 | | |
| |||
0 commit comments