From 551820ff00d2f927f4ad42808b410b1fb4d8fbb1 Mon Sep 17 00:00:00 2001 From: Saransh Malik <56735972+saransh-malik@users.noreply.github.com> Date: Mon, 22 Feb 2021 12:47:47 +0530 Subject: [PATCH] Fix for freeze with dynamic list content --- src/index.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index a245deb..df96af4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -290,6 +290,7 @@ export class ScrollBottomSheet extends Component> { private didScrollUpAndPullDown: Animated.Node; private setTranslationY: Animated.Node; private extraOffset: Animated.Node; + private currentHeight: number private calculateNextSnapPoint: ( i?: number ) => number | Animated.Node; @@ -335,6 +336,7 @@ export class ScrollBottomSheet extends Component> { const drawerOldGestureState = new Value(-1); const lastSnapInRange = new Value(1); + this.currentHeight = 0 this.prevTranslateYOffset = new Value(initialSnap); this.translationY = new Value(initialSnap); @@ -667,6 +669,14 @@ export class ScrollBottomSheet extends Component> { } }; + + private onContentSizeChange = (_, height: number) => { + if (this.currentHeight > height) { + this.lastStartScrollY.setValue(0); + } + this.currentHeight = height; + }; + snapTo = (index: number) => { const snapPoints = this.getNormalisedSnapPoints(); this.isManuallySetValue.setValue(1); @@ -730,6 +740,7 @@ export class ScrollBottomSheet extends Component> { // @ts-ignore decelerationRate={this.decelerationRate} onScrollBeginDrag={this.onScrollBeginDrag} + onContentSizeChange={this.onContentSizeChange} scrollEventThrottle={1} contentContainerStyle={[ rest.contentContainerStyle,