From 738734de10a9d72cd46a4bae826313745e9e89b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Lach=C3=A8ze?= Date: Fri, 16 Oct 2020 19:31:50 +0200 Subject: [PATCH] Fix gh53: use only imperative methods --- src/index.tsx | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index a245deb..f4a1058 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -281,7 +281,7 @@ export class ScrollBottomSheet extends Component> { private lastStartScrollY: Animated.Value = new Value(0); private prevTranslateYOffset: Animated.Value; private translationY: Animated.Value; - private destSnapPoint = new Value(0); + private destSnapPoint = new Value(0); private lastSnap: Animated.Value; private dragWithHandle = new Value(0); @@ -558,6 +558,7 @@ export class ScrollBottomSheet extends Component> { set(this.dragWithHandle, 0), ]), set(this.isManuallySetValue, 0), + set(this.nextSnapIndex, 0), set(this.manualYOffset, 0), stopClock(clock), this.prevTranslateYOffset, @@ -670,8 +671,18 @@ export class ScrollBottomSheet extends Component> { snapTo = (index: number) => { const snapPoints = this.getNormalisedSnapPoints(); this.isManuallySetValue.setValue(1); - this.manualYOffset.setValue(snapPoints[index]); + const yOffset = snapPoints[index]; + this.manualYOffset.setValue(yOffset); this.nextSnapIndex.setValue(index); + + this.destSnapPoint.setValue(yOffset); + this.animationFinished.setValue(0); + this.lastSnap.setValue(yOffset); + // This is the TapGHandler trick + // @ts-ignore + this.masterDrawer?.current?.setNativeProps({ + maxDeltaY: yOffset - this.getNormalisedSnapPoints()[0], + }); }; render() { @@ -828,26 +839,6 @@ export class ScrollBottomSheet extends Component> { ]) )} /> - { - // This is the TapGHandler trick - // @ts-ignore - this.masterDrawer?.current?.setNativeProps({ - maxDeltaY: value - this.getNormalisedSnapPoints()[0], - }); - }), - ], - [set(this.nextSnapIndex, 0)] - ), - ])} - /> );