react-native-gesture-handler 2.11.0 → 2.12.1
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/android/build.gradle +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +10 -4
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +1 -1
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +10 -4
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/handlers/createHandler.js +1 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/package.json +2 -2
- package/src/components/touchables/GenericTouchable.tsx +14 -2
- package/src/components/touchables/TouchableOpacity.tsx +3 -1
- package/src/handlers/createHandler.tsx +1 -1
- package/src/handlers/gestures/GestureDetector.tsx +1 -1
@@ -250,6 +250,16 @@ export default class GenericTouchable extends Component<
|
|
250
250
|
}
|
251
251
|
|
252
252
|
render() {
|
253
|
+
const hitSlop =
|
254
|
+
(typeof this.props.hitSlop === 'number'
|
255
|
+
? {
|
256
|
+
top: this.props.hitSlop,
|
257
|
+
left: this.props.hitSlop,
|
258
|
+
bottom: this.props.hitSlop,
|
259
|
+
right: this.props.hitSlop,
|
260
|
+
}
|
261
|
+
: this.props.hitSlop) ?? undefined;
|
262
|
+
|
253
263
|
const coreProps = {
|
254
264
|
accessible: this.props.accessible !== false,
|
255
265
|
accessibilityLabel: this.props.accessibilityLabel,
|
@@ -262,7 +272,9 @@ export default class GenericTouchable extends Component<
|
|
262
272
|
onAccessibilityAction: this.props.onAccessibilityAction,
|
263
273
|
nativeID: this.props.nativeID,
|
264
274
|
onLayout: this.props.onLayout,
|
265
|
-
hitSlop:
|
275
|
+
hitSlop: hitSlop as
|
276
|
+
| Animated.WithAnimatedObject<typeof hitSlop>
|
277
|
+
| undefined,
|
266
278
|
};
|
267
279
|
|
268
280
|
return (
|
@@ -273,7 +285,7 @@ export default class GenericTouchable extends Component<
|
|
273
285
|
this.props.disabled ? undefined : this.onHandlerStateChange
|
274
286
|
}
|
275
287
|
onGestureEvent={this.onGestureEvent}
|
276
|
-
hitSlop={
|
288
|
+
hitSlop={hitSlop}
|
277
289
|
shouldActivateOnStart={this.props.shouldActivateOnStart}
|
278
290
|
disallowInterruption={this.props.disallowInterruption}
|
279
291
|
testID={this.props.testID}
|
@@ -30,7 +30,9 @@ export default class TouchableOpacity extends Component<
|
|
30
30
|
// opacity is 1 one by default but could be overwritten
|
31
31
|
getChildStyleOpacityWithDefault = () => {
|
32
32
|
const childStyle = StyleSheet.flatten(this.props.style) || {};
|
33
|
-
return childStyle.opacity == null
|
33
|
+
return childStyle.opacity == null
|
34
|
+
? 1
|
35
|
+
: (childStyle.opacity.valueOf() as number);
|
34
36
|
};
|
35
37
|
|
36
38
|
opacity = new Animated.Value(this.getChildStyleOpacityWithDefault());
|
@@ -402,7 +402,7 @@ export default function createHandler<
|
|
402
402
|
}
|
403
403
|
|
404
404
|
render() {
|
405
|
-
if (__DEV__ && !this.context && !isJestEnv()) {
|
405
|
+
if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {
|
406
406
|
throw new Error(
|
407
407
|
name +
|
408
408
|
' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
@@ -612,7 +612,7 @@ interface GestureDetectorState {
|
|
612
612
|
}
|
613
613
|
export const GestureDetector = (props: GestureDetectorProps) => {
|
614
614
|
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
615
|
-
if (__DEV__ && !rootViewContext && !isJestEnv()) {
|
615
|
+
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
|
616
616
|
throw new Error(
|
617
617
|
'GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
618
618
|
);
|