diff --git a/README.md b/README.md index e243a0d..1a5d16c 100644 --- a/README.md +++ b/README.md @@ -489,6 +489,7 @@ return ( | pickerContainerProps | Props for the picker container | `React.ComponentProps` | - | false | | pickerGradientOverlayProps | Props for the gradient overlay (supply a different `locations` array to adjust its position) overlays | `Partial` | - | 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 👗 diff --git a/src/components/DurationScroll/index.tsx b/src/components/DurationScroll/index.tsx index 7f83a96..fbfb7b9 100644 --- a/src/components/DurationScroll/index.tsx +++ b/src/components/DurationScroll/index.tsx @@ -35,6 +35,7 @@ const DurationScroll = forwardRef( amLabel, Audio, clickSoundAsset, + decelerationRate = 0.88, disableInfiniteScroll = false, FlatList = RNFlatList, Haptics, @@ -504,7 +505,7 @@ const DurationScroll = forwardRef( styles.durationScrollFlatListContentContainer } data={numbersForFlatList} - decelerationRate={0.88} + decelerationRate={decelerationRate} getItemLayout={getItemLayout} initialScrollIndex={initialScrollIndex} keyExtractor={(_, index) => index.toString()} @@ -561,6 +562,7 @@ const DurationScroll = forwardRef( styles.pickerLabel, styles.pickerLabelContainer, viewabilityConfigCallbackPairs, + decelerationRate, ]); const renderLinearGradient = useMemo(() => { diff --git a/src/components/DurationScroll/types.ts b/src/components/DurationScroll/types.ts index 10cf46f..9f00f1c 100644 --- a/src/components/DurationScroll/types.ts +++ b/src/components/DurationScroll/types.ts @@ -26,6 +26,7 @@ export interface DurationScrollProps { allowFontScaling?: boolean; amLabel?: string; clickSoundAsset?: SoundAssetType; + decelerationRate?: number | "normal" | "fast"; disableInfiniteScroll?: boolean; initialValue?: number; interval: number; diff --git a/src/components/TimerPicker/index.tsx b/src/components/TimerPicker/index.tsx index 4e8ea92..1079197 100644 --- a/src/components/TimerPicker/index.tsx +++ b/src/components/TimerPicker/index.tsx @@ -22,6 +22,7 @@ const TimerPicker = forwardRef( aggressivelyGetLatestDuration = false, allowFontScaling = false, amLabel = "am", + decelerationRate = 0.88, disableInfiniteScroll = false, hideHours = false, hideMinutes = false, @@ -153,6 +154,7 @@ const TimerPicker = forwardRef( } allowFontScaling={allowFontScaling} amLabel={amLabel} + decelerationRate={decelerationRate} disableInfiniteScroll={disableInfiniteScroll} initialValue={safeInitialValue.hours} interval={hourInterval} @@ -183,6 +185,7 @@ const TimerPicker = forwardRef( aggressivelyGetLatestDuration } allowFontScaling={allowFontScaling} + decelerationRate={decelerationRate} disableInfiniteScroll={disableInfiniteScroll} initialValue={safeInitialValue.minutes} interval={minuteInterval} @@ -209,6 +212,7 @@ const TimerPicker = forwardRef( aggressivelyGetLatestDuration } allowFontScaling={allowFontScaling} + decelerationRate={decelerationRate} disableInfiniteScroll={disableInfiniteScroll} initialValue={safeInitialValue.seconds} interval={secondInterval} diff --git a/src/components/TimerPicker/types.ts b/src/components/TimerPicker/types.ts index ca73f46..b5e46c0 100644 --- a/src/components/TimerPicker/types.ts +++ b/src/components/TimerPicker/types.ts @@ -42,6 +42,7 @@ export interface TimerPickerProps { allowFontScaling?: boolean; amLabel?: string; clickSoundAsset?: SoundAssetType; + decelerationRate?: number | "normal" | "fast"; disableInfiniteScroll?: boolean; hideHours?: boolean; hideMinutes?: boolean;