diff --git a/src/components/bottomSheet/BottomSheet.tsx b/src/components/bottomSheet/BottomSheet.tsx index b1664407..3b1264fb 100644 --- a/src/components/bottomSheet/BottomSheet.tsx +++ b/src/components/bottomSheet/BottomSheet.tsx @@ -679,6 +679,7 @@ const BottomSheetComponent = forwardRef( currentPosition: animatedPosition.value, position, velocity, + animatedContainerHeight: animatedContainerHeight.value, }, }); @@ -1291,6 +1292,31 @@ const BottomSheetComponent = forwardRef( const _previousSnapPoints = _previousResult?.snapPoints; const _previousContainerHeight = _previousResult?.containerHeight; + let nextPosition; + let animationConfig; + let animationSource = ANIMATION_SOURCE.SNAP_POINT_CHANGE; + + /** + * if the bottom sheet is closing and the container gets resized, + * then we restart the closing animation to the new position. + */ + if ( + animatedAnimationState.value === ANIMATION_STATE.RUNNING && + animatedNextPositionIndex.value === -1 && + _previousContainerHeight !== containerHeight + ) { + animationSource = ANIMATION_SOURCE.CONTAINER_RESIZE; + animationConfig = { + duration: 0, + }; + animateToPosition( + containerHeight, + animationSource, + 0, + animationConfig + ); + } + if ( JSON.stringify(snapPoints) === JSON.stringify(_previousSnapPoints) || !isLayoutCalculated.value || @@ -1308,10 +1334,6 @@ const BottomSheetComponent = forwardRef( }, }); - let nextPosition; - let animationConfig; - let animationSource = ANIMATION_SOURCE.SNAP_POINT_CHANGE; - /** * if snap points changed while sheet is animating, then * we stop the animation and animate to the updated point.