Skip to content

Commit

Permalink
fix: prevent animatedPosition from becoming undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed May 16, 2021
1 parent 01f791e commit 400d7b9
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
//#region extract props
const {
// animations configurations
animationDuration: _providedAnimationDuration = DEFAULT_ANIMATION_DURATION,
animationDuration:
_providedAnimationDuration = DEFAULT_ANIMATION_DURATION,
animationEasing: _providedAnimationEasing = DEFAULT_ANIMATION_EASING,
animationConfigs: _providedAnimationConfigs,

Expand Down Expand Up @@ -501,41 +502,37 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
//#endregion

//#region gesture interaction hooks
const [
contentPanGestureHandler,
contentPanGestureState,
] = useInteractivePanGestureHandler({
type: GESTURE.CONTENT,
enableOverDrag,
enablePanDownToClose,
overDragResistanceFactor,
keyboardState,
keyboardHeight,
keyboardBehavior: keyboardBehavior,
animatedPosition,
animatedSnapPoints,
animatedContainerHeight,
isExtendedByKeyboard: isInTemporaryPosition,
scrollableContentOffsetY,
animateToPoint: animateToPosition,
});
const [
handlePanGestureHandler,
handlePanGestureState,
] = useInteractivePanGestureHandler({
type: GESTURE.HANDLE,
enableOverDrag,
enablePanDownToClose,
overDragResistanceFactor,
keyboardState,
keyboardHeight,
keyboardBehavior,
animatedPosition,
animatedSnapPoints,
animatedContainerHeight,
isExtendedByKeyboard: isInTemporaryPosition,
animateToPoint: animateToPosition,
});
const [contentPanGestureHandler, contentPanGestureState] =
useInteractivePanGestureHandler({
type: GESTURE.CONTENT,
enableOverDrag,
enablePanDownToClose,
overDragResistanceFactor,
keyboardState,
keyboardHeight,
keyboardBehavior: keyboardBehavior,
animatedPosition,
animatedSnapPoints,
animatedContainerHeight,
isExtendedByKeyboard: isInTemporaryPosition,
scrollableContentOffsetY,
animateToPoint: animateToPosition,
});
const [handlePanGestureHandler, handlePanGestureState] =
useInteractivePanGestureHandler({
type: GESTURE.HANDLE,
enableOverDrag,
enablePanDownToClose,
overDragResistanceFactor,
keyboardState,
keyboardHeight,
keyboardBehavior,
animatedPosition,
animatedSnapPoints,
animatedContainerHeight,
isExtendedByKeyboard: isInTemporaryPosition,
animateToPoint: animateToPosition,
});
//#endregion

//#region public methods
Expand Down Expand Up @@ -847,7 +844,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
},
});

const nextPosition = _animatedSnapPoints[animatedCurrentIndex.value];
let nextPosition;
if (animatedCurrentIndex.value === -1) {
nextPosition = animatedContainerHeight.value;
} else {
nextPosition = _animatedSnapPoints[animatedCurrentIndex.value];
}
animateToPosition(nextPosition);
}
);
Expand Down

0 comments on commit 400d7b9

Please sign in to comment.