Skip to content

Commit d66fae4

Browse files
meishuuyayvery
authored andcommitted
fix onAnimate index when close()d on mount
1 parent c6e661e commit d66fae4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
618618
const handleOnAnimate = useCallback(
619619
function handleOnAnimate(toPoint: number) {
620620
const snapPoints = animatedSnapPoints.value;
621-
const toIndex = snapPoints.indexOf(toPoint);
621+
const closedPosition = animatedClosedPosition.value;
622+
const toIndex =
623+
toPoint === closedPosition ? -1 : snapPoints.indexOf(toPoint);
622624

623625
print({
624626
component: BottomSheet.name,
@@ -637,7 +639,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
637639
_providedOnAnimate(animatedCurrentIndex.value, toIndex);
638640
}
639641
},
640-
[_providedOnAnimate, animatedSnapPoints, animatedCurrentIndex]
642+
[
643+
_providedOnAnimate,
644+
animatedSnapPoints,
645+
animatedClosedPosition,
646+
animatedCurrentIndex,
647+
]
641648
);
642649
//#endregion
643650

0 commit comments

Comments
 (0)