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
29 changes: 29 additions & 0 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,26 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
return SCROLLABLE_STATE.LOCKED;
});
// dynamic
const isContainerHeightCollapsing = useSharedValue<boolean>(false);
useAnimatedReaction(
() => animatedSheetHeight.value,
(cur, prev) => {
isContainerHeightCollapsing.value = !!(prev && cur < prev);
}
);
useEffect(() => {
let timeout: any;

// if we're beginning a window collapse start a timer to flag it as
// completed as a failsafe.
if (isContainerHeightCollapsing.value) {
timeout = setTimeout(() => {
isContainerHeightCollapsing.value = false;
}, 100);
}

return () => timeout && clearTimeout(timeout);
}, [isContainerHeightCollapsing]);
const animatedContentHeight = useDerivedValue(() => {
const keyboardHeightInContainer = animatedKeyboardHeightInContainer.value;
const handleHeight = Math.max(0, animatedHandleHeight.value);
Expand Down Expand Up @@ -475,6 +495,15 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
)
: -1;

/**
* Don't adjust the animatedIndex if the calculation is triggered
* by the collapse in height of the window.
*/
if (isContainerHeightCollapsing.value === true) {
isContainerHeightCollapsing.value = false;
return animatedCurrentIndex.value;
}

/**
* if the sheet is currently running an animation by the keyboard opening,
* then we clamp the index on android with resize keyboard mode.
Expand Down