Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
feat: disable gesture logic when no gesture stack
Browse files Browse the repository at this point in the history
  • Loading branch information
osdnk committed Aug 28, 2019
1 parent fc37e93 commit 38336b0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,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(
Expand Down Expand Up @@ -454,10 +463,6 @@ export default class Card extends React.Component<Props> {
),
]
),
onChange(
this.isVisible,
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
),
]);

private handleGestureEventHorizontal = Animated.event([
Expand Down Expand Up @@ -576,15 +581,21 @@ export default class Card extends React.Component<Props> {
layout
);

const handleGestureEvent =
gestureDirection === 'vertical'
const handleGestureEvent = gestureEnabled
? gestureDirection === 'vertical'
? 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"
Expand Down

0 comments on commit 38336b0

Please sign in to comment.