Skip to content

Commit

Permalink
fix: prevent the sheet from snapping while layout being calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Aug 22, 2021
1 parent 3dd5796 commit 445a964
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,10 +743,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(

/**
* exit method if :
* - layout is not calculated.
* - already animating to next position.
* - sheet is forced closing.
*/
if (
!isLayoutCalculated.value ||
index === animatedNextPositionIndex.value ||
nextPosition === animatedNextPosition.value ||
isForcedClosing.value
Expand All @@ -768,6 +770,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
},
[
animateToPosition,
isLayoutCalculated,
isInTemporaryPosition,
isForcedClosing,
animatedSnapPoints,
Expand Down Expand Up @@ -800,10 +803,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(

/**
* exit method if :
* - layout is not calculated.
* - already animating to next position.
* - sheet is forced closing.
*/
if (
!isLayoutCalculated ||
nextPosition === animatedNextPosition.value ||
isForcedClosing.value
) {
Expand All @@ -826,6 +831,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
animateToPosition,
bottomInset,
topInset,
isLayoutCalculated,
isForcedClosing,
animatedContainerHeight,
animatedPosition,
Expand All @@ -844,10 +850,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(

/**
* exit method if :
* - layout is not calculated.
* - already animating to next position.
* - sheet is forced closing.
*/
if (
!isLayoutCalculated.value ||
nextPosition === animatedNextPosition.value ||
isForcedClosing.value
) {
Expand All @@ -869,6 +877,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
[
animateToPosition,
isForcedClosing,
isLayoutCalculated,
isInTemporaryPosition,
animatedNextPosition,
animatedClosedPosition,
Expand Down Expand Up @@ -936,10 +945,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(

/**
* exit method if :
* - layout is not calculated.
* - already animating to next position.
* - sheet is forced closing.
*/
if (
!isLayoutCalculated.value ||
snapPoints.length - 1 === animatedNextPositionIndex.value ||
nextPosition === animatedNextPosition.value ||
isForcedClosing.value
Expand All @@ -962,6 +973,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
[
animateToPosition,
isInTemporaryPosition,
isLayoutCalculated,
isForcedClosing,
animatedSnapPoints,
animatedNextPosition,
Expand All @@ -981,10 +993,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(

/**
* exit method if :
* - layout is not calculated.
* - already animating to next position.
* - sheet is forced closing.
*/
if (
!isLayoutCalculated ||
animatedNextPositionIndex.value === 0 ||
nextPosition === animatedNextPosition.value ||
isForcedClosing.value
Expand All @@ -1007,6 +1021,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
[
animateToPosition,
isForcedClosing,
isLayoutCalculated,
isInTemporaryPosition,
animatedSnapPoints,
animatedNextPosition,
Expand Down

0 comments on commit 445a964

Please sign in to comment.