From 52f9bcecd331393d595411a1c32717de5f00e29d Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Sat, 8 Dec 2018 18:09:18 -0800 Subject: [PATCH] Animations interruptible with gesture and comment for more info --- src/views/StackView/StackViewLayout.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/views/StackView/StackViewLayout.js b/src/views/StackView/StackViewLayout.js index b7b9e05..a5bc039 100644 --- a/src/views/StackView/StackViewLayout.js +++ b/src/views/StackView/StackViewLayout.js @@ -446,10 +446,20 @@ class StackViewLayout extends React.Component { this._handleReleaseHorizontal(nativeEvent); } } else if (nativeEvent.state === State.ACTIVE) { - // HACK if current is in animation don't start gesture - if (!this.props.transitionProps.position._animation) { - this.positionSwitch.setValue(0); - } + // Switch to using gesture position + this.positionSwitch.setValue(0); + + // By enabling the gesture switch and ignoring the position here we + // end up with a quick jump to the initial value and then back to the + // gesture. While this isn't ideal, it's preferred over preventing new + // gestures during the animation (all gestures should be interruptible) + // and we will properly fix it (interruptible and from the correct position) + // when we integrate reanimated. If you prefer to prevent gestures during + // transitions, then fork this library, comment the positionSwitch value set above, + // and uncomment the following two lines. + // if (!this.props.transitionProps.position._animation) { + // this.positionSwitch.setValue(0); + // } } };