Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updated decelerationRate per platform #36

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
BottomSheetProvider,
} from '../../contexts';
import {
NORMAL_DECELERATION_RATE,
DEFAULT_ANIMATION_EASING,
DEFAULT_ANIMATION_DURATION,
GESTURE,
Expand Down Expand Up @@ -219,7 +220,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
/**
* Scrollable animated props.
*/
const decelerationRate = cond(greaterThan(position, 0), 0.001, 0.999);
const decelerationRate = cond(
greaterThan(position, 0),
0.001,
NORMAL_DECELERATION_RATE
);
//#endregion

//#region styles
Expand Down Expand Up @@ -291,11 +296,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
const handleExpand = useCallback(() => {
manualSnapToPoint.setValue(snapPoints[snapPoints.length - 1]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sheetHeight]);
}, [snapPoints]);
const handleCollapse = useCallback(() => {
manualSnapToPoint.setValue(snapPoints[0]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sheetHeight]);
}, [snapPoints]);
//#endregion

//#region
Expand Down Expand Up @@ -357,8 +362,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
return;
}
currentPositionIndexRef.current = currentPositionIndex;
handleOnChange(currentPositionIndex);
refreshUIElements();
handleOnChange(currentPositionIndex);
}),
]),
[snapPoints, refreshUIElements]
Expand Down
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Platform } from 'react-native';
import Animated from 'react-native-reanimated';

const {
Expand All @@ -11,6 +12,11 @@ export const DEFAULT_ANIMATION_EASING: Animated.EasingFunction = Easing.out(
);
export const DEFAULT_ANIMATION_DURATION = 500;

export const NORMAL_DECELERATION_RATE = Platform.select({
ios: 0.998,
android: 0.985,
});

export enum GESTURE {
UNDETERMINED = 0,
CONTENT,
Expand Down