feat: disable attaching nodes when gestureEnabled set to false (#194)

This commit is contained in:
Michał Osadnik
2019-08-28 11:17:06 +01:00
parent f0bd7adc68
commit e22a0213c8

View File

@@ -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"