Fix reaction list cutoff at end of list (#2424)

This commit is contained in:
Elias Nahum 2018-12-07 12:14:36 -03:00 committed by GitHub
parent dd8a9d879d
commit e89de72b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -140,6 +140,7 @@ export default class SlideUpPanel extends PureComponent {
onHeaderHandlerStateChange = ({nativeEvent}) => {
if (nativeEvent.oldState === GestureState.BEGAN) {
this.lastScrollY.setValue(0);
this.lastScrollYValue = 0;
}
this.onHandlerStateChange({nativeEvent});
};
@ -155,7 +156,7 @@ export default class SlideUpPanel extends PureComponent {
const endOffsetY = lastSnap + translation;
let destSnapPoint = this.snapPoints[0];
if (Math.abs(translationY) < 50) {
if (Math.abs(translationY) < 50 && allowStayMiddle) {
// Only drag the panel after moving 50 or more points
destSnapPoint = lastSnap;
} else if (isGoingDown && !allowStayMiddle) {
@ -184,6 +185,11 @@ export default class SlideUpPanel extends PureComponent {
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();
}
});
}
} else {
@ -284,6 +290,7 @@ export default class SlideUpPanel extends PureComponent {
bounces={false}
onScrollBeginDrag={this.onRegisterLastScroll}
scrollEventThrottle={1}
style={{marginBottom: (this.props.marginFromTop + BOTTOM_MARGIN)}}
>
{children}
</Animated.ScrollView>