Skip to content

Commit

Permalink
fix: updated decelerationRate per platform (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhom committed Sep 26, 2020
1 parent 323cc4d commit 9d6fb6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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

0 comments on commit 9d6fb6c

Please sign in to comment.