Skip to content

Commit 591f943

Browse files
committed
Fix android issues with dynamic snap points and open keyboard + onAnimate values gorhom#1163
1 parent 3998456 commit 591f943

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,9 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
602602
);
603603
const handleOnAnimate = useCallback(
604604
function handleOnAnimate(toPoint: number) {
605+
const keyboardOffset = animatedKeyboardState.value == KEYBOARD_STATE.SHOWN ? animatedKeyboardHeight.value : 0;
605606
const snapPoints = animatedSnapPoints.value;
606-
const toIndex = snapPoints.indexOf(toPoint);
607+
const toIndex = toPoint == 0 ? INITIAL_SNAP_POINT : snapPoints.indexOf(toPoint + keyboardOffset);
607608

608609
print({
609610
component: BottomSheet.name,
@@ -693,9 +694,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
693694
/**
694695
* store next position
695696
*/
696-
animatedNextPosition.value = position;
697-
animatedNextPositionIndex.value =
698-
animatedSnapPoints.value.indexOf(position);
697+
const keyboardOffset = animatedKeyboardState.value == KEYBOARD_STATE.SHOWN ? animatedKeyboardHeight.value : 0;
698+
699+
animatedNextPosition.value = position + keyboardOffset;
700+
animatedNextPositionIndex.value = position == 0 ? INITIAL_SNAP_POINT : animatedSnapPoints.value.indexOf(position + keyboardOffset);
699701

700702
/**
701703
* fire `onAnimate` callback

0 commit comments

Comments
 (0)