Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,9 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
);
const handleOnAnimate = useCallback(
function handleOnAnimate(toPoint: number) {
const keyboardOffset = animatedKeyboardState.value == KEYBOARD_STATE.SHOWN ? animatedKeyboardHeight.value : 0;
const snapPoints = animatedSnapPoints.value;
const toIndex = snapPoints.indexOf(toPoint);
const toIndex = toPoint == 0 ? INITIAL_SNAP_POINT : snapPoints.indexOf(toPoint + keyboardOffset);

print({
component: BottomSheet.name,
Expand Down Expand Up @@ -693,9 +694,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
/**
* store next position
*/
animatedNextPosition.value = position;
animatedNextPositionIndex.value =
animatedSnapPoints.value.indexOf(position);
const keyboardOffset = animatedKeyboardState.value == KEYBOARD_STATE.SHOWN ? animatedKeyboardHeight.value : 0;

animatedNextPosition.value = position + keyboardOffset;
animatedNextPositionIndex.value = position == 0 ? INITIAL_SNAP_POINT : animatedSnapPoints.value.indexOf(position + keyboardOffset);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the position was 0 (from a fully extended sheet), the index was still specified as -1. But that had the implication that the sheet was closed/closing.
I thought to instead set it to INITIAL_SNAP_POINT (-999), as that conveys a better meaning, especially in the context of the onAnimate callback


/**
* fire `onAnimate` callback
Expand Down