Edited onHandlerStateChange to fix reaction list stutter (#3951)
This commit is contained in:
parent
28384bc9d2
commit
4668c9cce5
1 changed files with 21 additions and 25 deletions
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue