Skip to content

Commit

Permalink
fix: updated keyboard height in container calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed May 26, 2021
1 parent ee97c02 commit 2599f6c
Showing 1 changed file with 45 additions and 31 deletions.
76 changes: 45 additions & 31 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
return $modal
? keyboardHeight.value -
Math.abs(bottomInset - animatedContainerOffset.value.bottom)
: keyboardHeight.value;
: keyboardHeight.value - animatedContainerOffset.value.bottom;
}, [$modal, bottomInset]);
//#endregion

Expand Down Expand Up @@ -596,18 +596,23 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
snapPoints.length - 1
}`
);
print({
component: BottomSheet.name,
method: handleSnapToIndex.name,
params: {
index,
},
});

/**
* verify if sheet is closed.
*/
if (animatedPosition.value === animatedContainerHeight.value) {
isSheetClosing.value = false;
}

/**
* exit method if sheet is closing.
*/
if (isSheetClosing.value) {
} else if (isSheetClosing.value) {
/**
* exit method if sheet is closing.
*/
return;
}

Expand All @@ -627,17 +632,22 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
position: number | string,
animationConfigs?: Animated.WithSpringConfig | Animated.WithTimingConfig
) {
print({
component: BottomSheet.name,
method: handleSnapToPosition.name,
params: {
position,
},
});
/**
* verify if sheet is closed.
*/
if (animatedPosition.value === animatedContainerHeight.value) {
isSheetClosing.value = false;
}

/**
* exit method if sheet is closing.
*/
if (isSheetClosing.value) {
} else if (isSheetClosing.value) {
/**
* exit method if sheet is closing.
*/
return;
}

Expand Down Expand Up @@ -674,17 +684,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
component: BottomSheet.name,
method: handleClose.name,
});

/**
* verify if sheet is closed.
*/
if (animatedPosition.value === animatedContainerHeight.value) {
isSheetClosing.value = false;
}

/**
* exit method if sheet is closing.
*/
if (isSheetClosing.value) {
} else if (isSheetClosing.value) {
/**
* exit method if sheet is closing.
*/
return;
}

Expand All @@ -706,19 +715,22 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
function handleExpand(
animationConfigs?: Animated.WithSpringConfig | Animated.WithTimingConfig
) {
print({
component: BottomSheet.name,
method: handleExpand.name,
});
/**
* verify if sheet is closed.
*/
if (animatedPosition.value === animatedContainerHeight.value) {
isSheetClosing.value = false;
}

/**
* exit method if sheet is closing.
*/
if (isSheetClosing.value) {
} else if (isSheetClosing.value) {
/**
* exit method if sheet is closing.
*/
return;
}

const snapPoints = animatedSnapPoints.value;
const newSnapPoint = snapPoints[snapPoints.length - 1];
runOnUI(animateToPosition)(newSnapPoint, 0, animationConfigs);
Expand All @@ -735,17 +747,19 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
function handleCollapse(
animationConfigs?: Animated.WithSpringConfig | Animated.WithTimingConfig
) {
print({
component: BottomSheet.name,
method: handleCollapse.name,
});
/**
* verify if sheet is closed.
*/
if (animatedPosition.value === animatedContainerHeight.value) {
isSheetClosing.value = false;
}

/**
* exit method if sheet is closing.
*/
if (isSheetClosing.value) {
} else if (isSheetClosing.value) {
/**
* exit method if sheet is closing.
*/
return;
}

Expand Down

0 comments on commit 2599f6c

Please sign in to comment.