@@ -11,6 +11,7 @@ export type SimpleImageSliderProps = {
11
11
style ?: React . CSSProperties ;
12
12
showNavs : boolean ;
13
13
showBullets : boolean ;
14
+ startIndex ?: number ;
14
15
slideDuration ?: number ;
15
16
bgColor ?: string ;
16
17
useGPURender ?: boolean ;
@@ -30,6 +31,7 @@ const SimpleImageSlider: React.FC<SimpleImageSliderProps> = ({
30
31
images,
31
32
showNavs,
32
33
showBullets,
34
+ startIndex = 0 ,
33
35
style = undefined ,
34
36
slideDuration = 0.5 ,
35
37
bgColor = '#000' ,
@@ -44,7 +46,7 @@ const SimpleImageSlider: React.FC<SimpleImageSliderProps> = ({
44
46
onCompleteSlide = undefined
45
47
} : SimpleImageSliderProps ) => {
46
48
const rootStyle : React . CSSProperties = useMemo ( ( ) => styles . getRootContainer ( width , height , bgColor ) , [ width , height , bgColor ] ) ;
47
- const [ slideIdx , setSlideIdx ] = useState ( 0 ) ;
49
+ const [ slideIdx , setSlideIdx ] = useState ( startIndex < images . length ? startIndex : 0 ) ;
48
50
const [ slideDirection , setSlideDirection ] = useState ( ImageSliderNavDirection . RIGHT ) ;
49
51
const [ isSliding , setIsSliding ] = useState ( false ) ;
50
52
const [ currentSliderStyle , setCurrentSlideStyle ] = useState ( styles . getImageSlide ( images [ 0 ] . url , slideDuration , 0 , useGPURender ) ) ;
0 commit comments