Skip to content

Added decelerationProp to TimerPicker #57

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ return (
| pickerContainerProps | Props for the picker container | `React.ComponentProps<typeof View>` | - | false |
| pickerGradientOverlayProps | Props for the gradient overlay (supply a different `locations` array to adjust its position) overlays | `Partial<LinearGradientProps>` | - | false |
| styles | Custom styles for the timer picker | [CustomTimerPickerStyles](#custom-styles-) | - | false |
| decelerationRate | Set how quickly the picker decelerates after the user lifts their finger | 'fast', 'normal', or Number | 0.88 | false |

#### Custom Styles 👗

Expand Down
4 changes: 3 additions & 1 deletion src/components/DurationScroll/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
amLabel,
Audio,
clickSoundAsset,
decelerationRate = 0.88,
disableInfiniteScroll = false,
FlatList = RNFlatList,
Haptics,
Expand Down Expand Up @@ -504,7 +505,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
styles.durationScrollFlatListContentContainer
}
data={numbersForFlatList}
decelerationRate={0.88}
decelerationRate={decelerationRate}
getItemLayout={getItemLayout}
initialScrollIndex={initialScrollIndex}
keyExtractor={(_, index) => index.toString()}
Expand Down Expand Up @@ -561,6 +562,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
styles.pickerLabel,
styles.pickerLabelContainer,
viewabilityConfigCallbackPairs,
decelerationRate,
]);

const renderLinearGradient = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions src/components/DurationScroll/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface DurationScrollProps {
allowFontScaling?: boolean;
amLabel?: string;
clickSoundAsset?: SoundAssetType;
decelerationRate?: number | "normal" | "fast";
disableInfiniteScroll?: boolean;
initialValue?: number;
interval: number;
Expand Down
4 changes: 4 additions & 0 deletions src/components/TimerPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
aggressivelyGetLatestDuration = false,
allowFontScaling = false,
amLabel = "am",
decelerationRate = 0.88,
disableInfiniteScroll = false,
hideHours = false,
hideMinutes = false,
Expand Down Expand Up @@ -153,6 +154,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
}
allowFontScaling={allowFontScaling}
amLabel={amLabel}
decelerationRate={decelerationRate}
disableInfiniteScroll={disableInfiniteScroll}
initialValue={safeInitialValue.hours}
interval={hourInterval}
Expand Down Expand Up @@ -183,6 +185,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
aggressivelyGetLatestDuration
}
allowFontScaling={allowFontScaling}
decelerationRate={decelerationRate}
disableInfiniteScroll={disableInfiniteScroll}
initialValue={safeInitialValue.minutes}
interval={minuteInterval}
Expand All @@ -209,6 +212,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
aggressivelyGetLatestDuration
}
allowFontScaling={allowFontScaling}
decelerationRate={decelerationRate}
disableInfiniteScroll={disableInfiniteScroll}
initialValue={safeInitialValue.seconds}
interval={secondInterval}
Expand Down
1 change: 1 addition & 0 deletions src/components/TimerPicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface TimerPickerProps {
allowFontScaling?: boolean;
amLabel?: string;
clickSoundAsset?: SoundAssetType;
decelerationRate?: number | "normal" | "fast";
disableInfiniteScroll?: boolean;
hideHours?: boolean;
hideMinutes?: boolean;
Expand Down