File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1313| defaultIndex | ❌ | 0 | number | Default index |
1414| autoPlay | ❌ | false | boolean | Auto play |
1515| autoPlayReverse | ❌ | false | boolean | Auto play reverse playback |
16- | autoPlayInterval | ❌ | 1000 | autoPlayInterval | Auto play playback interval |
16+ | autoPlayInterval | ❌ | 1000 | number | Auto play playback interval |
17+ | scrollAnimationDuration | ❌ | 500 | number | Time a scroll animation takes to finish |
1718| loop | ❌ | true | boolean | Carousel loop playback |
1819| onSnapToItem | ❌ | | (index: number) => void | Callback fired when navigating to an item |
1920| onScrollBegin | ❌ | | () => void | Callback fired when scroll begin |
Original file line number Diff line number Diff line change 11import React , { PropsWithChildren } from 'react' ;
22import Animated , { runOnJS , useDerivedValue } from 'react-native-reanimated' ;
3+
34import { useCarouselController } from './hooks/useCarouselController' ;
45import { useAutoPlay } from './hooks/useAutoPlay' ;
56import { usePropsErrorBoundary } from './hooks/usePropsErrorBoundary' ;
67import { ScrollViewGesture } from './ScrollViewGesture' ;
78import { useVisibleRanges } from './hooks/useVisibleRanges' ;
9+
810import type { ICarouselInstance , TCarouselProps } from './types' ;
911import { StyleSheet , View } from 'react-native' ;
1012import { DATA_LENGTH } from './constants' ;
@@ -33,6 +35,7 @@ function Carousel<T>(
3335 windowSize,
3436 autoPlayReverse,
3537 autoPlayInterval,
38+ scrollAnimationDuration,
3639 renderItem,
3740 onScrollEnd,
3841 onSnapToItem,
@@ -67,7 +70,7 @@ function Carousel<T>(
6770 onScrollEnd : ( ) => runOnJS ( _onScrollEnd ) ( ) ,
6871 onScrollBegin : ( ) => ! ! onScrollBegin && runOnJS ( onScrollBegin ) ( ) ,
6972 onChange : ( i ) => onSnapToItem && runOnJS ( onSnapToItem ) ( i ) ,
70- duration : autoPlayInterval ,
73+ duration : scrollAnimationDuration ,
7174 } ) ;
7275
7376 const {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export function useInitProps<T>(
1717 data : _data = [ ] ,
1818 loop = true ,
1919 autoPlayInterval = 1000 ,
20+ scrollAnimationDuration = 500 ,
2021 style = { } ,
2122 panGestureHandlerProps = { } ,
2223 pagingEnabled = true ,
@@ -55,6 +56,7 @@ export function useInitProps<T>(
5556 data,
5657 loop,
5758 autoPlayInterval,
59+ scrollAnimationDuration,
5860 style,
5961 panGestureHandlerProps,
6062 pagingEnabled,
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ export type TCarouselProps<T = any> = {
7171 * @description playback interval
7272 */
7373 autoPlayInterval ?: number ;
74+ /**
75+ * Time a scroll animation takes to finish
76+ * @default 500 (ms)
77+ */
78+ scrollAnimationDuration ?:number ;
7479 /**
7580 * Carousel container style
7681 */
You can’t perform that action at this time.
0 commit comments