Edited onHandlerStateChange to fix reaction list stutter (#3951)

This commit is contained in:
ami9000 2020-02-26 10:11:48 -08:00 committed by GitHub
parent 28384bc9d2
commit 4668c9cce5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -177,42 +177,38 @@ export default class SlideUpPanel extends PureComponent {
destSnapPoint = this.snapPoints[2];
} else if (isGoingDown) {
destSnapPoint = this.snapPoints.find((s) => s >= endOffsetY);
if (!destSnapPoint) {
destSnapPoint = this.snapPoints[2];
}
} else {
destSnapPoint = this.snapPoints.find((s) => s <= endOffsetY);
if (!destSnapPoint) {
destSnapPoint = this.snapPoints[0];
}
}
if (destSnapPoint) {
this.translateYOffset.extractOffset();
this.translateYOffset.setValue(translationY);
this.translateYOffset.flattenOffset();
this.dragY.setValue(0);
this.translateYOffset.extractOffset();
this.translateYOffset.setValue(translationY);
this.translateYOffset.flattenOffset();
this.dragY.setValue(0);
if (destSnapPoint === this.snapPoints[2]) {
this.closeWithAnimation();
} else {
Animated.spring(this.translateYOffset, {
velocity: velocityY,
tension: 68,
friction: 12,
toValue: destSnapPoint,
useNativeDriver: true,
}).start(() => {
this.setState({lastSnap: destSnapPoint});
// When dragging down the panel when is fully open reset the scrollView to the top
if (isGoingDown && destSnapPoint !== this.snapPoints[0]) {
this.scrollToTop();
}
});
}
if (destSnapPoint === this.snapPoints[2]) {
this.closeWithAnimation();
} else {
Animated.spring(this.translateYOffset, {
velocity: velocityY,
tension: 68,
friction: 12,
toValue: lastSnap,
toValue: destSnapPoint,
useNativeDriver: true,
}).start();
}).start(() => {
this.setState({lastSnap: destSnapPoint});
// When dragging down the panel when is fully open reset the scrollView to the top
if (isGoingDown && destSnapPoint !== this.snapPoints[0]) {
this.scrollToTop();
}
});
}
}
};