mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-13 22:30:41 +08:00
feat: disable attaching nodes when gestureEnabled set to false (#194)
This commit is contained in:
@@ -363,6 +363,15 @@ export default class Card extends React.Component<Props> {
|
||||
set(this.nextIsVisible, UNSET),
|
||||
])
|
||||
),
|
||||
onChange(
|
||||
this.isVisible,
|
||||
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
|
||||
),
|
||||
]);
|
||||
|
||||
private execNoGesture = this.runTransition(this.isVisible);
|
||||
|
||||
private execWithGesture = block([
|
||||
onChange(
|
||||
this.isSwiping,
|
||||
call(
|
||||
@@ -451,10 +460,6 @@ export default class Card extends React.Component<Props> {
|
||||
),
|
||||
]
|
||||
),
|
||||
onChange(
|
||||
this.isVisible,
|
||||
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
|
||||
),
|
||||
]);
|
||||
|
||||
private handleGestureEventHorizontal = Animated.event([
|
||||
@@ -595,16 +600,22 @@ export default class Card extends React.Component<Props> {
|
||||
layout
|
||||
);
|
||||
|
||||
const handleGestureEvent =
|
||||
gestureDirection === 'vertical' ||
|
||||
gestureDirection === 'vertical-inverted'
|
||||
const handleGestureEvent = gestureEnabled
|
||||
? gestureDirection === 'vertical' ||
|
||||
gestureDirection === 'vertical-inverted'
|
||||
? this.handleGestureEventVertical
|
||||
: this.handleGestureEventHorizontal;
|
||||
: this.handleGestureEventHorizontal
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<StackGestureContext.Provider value={this.gestureRef}>
|
||||
<View pointerEvents="box-none" {...rest}>
|
||||
<Animated.Code exec={this.exec} />
|
||||
{this.props.gestureEnabled ? (
|
||||
<Animated.Code exec={this.execNoGesture} />
|
||||
) : (
|
||||
<Animated.Code exec={this.execWithGesture} />
|
||||
)}
|
||||
{overlayEnabled && overlayStyle ? (
|
||||
<Animated.View
|
||||
pointerEvents="none"
|
||||
|
||||
Reference in New Issue
Block a user