File tree Expand file tree Collapse file tree 4 files changed +9
-0
lines changed
Expand file tree Collapse file tree 4 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ function SwiperExample({ theme }) {
3636 style = { { width : "100%" , height : 300 } }
3737 dotColor = "green"
3838 dotActiveColor = "red"
39+ onIndexChanged = { index => console . log ( "onIndexChanged: " , index ) }
3940 >
4041 < SwiperItem style = { [ style . item , { backgroundColor : "#fdd3d3" } ] } >
4142 < Text > Test Slide 1</ Text >
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export interface SwiperProps<T> {
1919 keyExtractor : ( item : T , index : number ) => string ;
2020 renderItem ?: ( { item, index } : { item : T ; index : number } ) => JSX . Element ;
2121 style ?: StyleProp < ViewStyle > ;
22+ onIndexChanged ?: ( index : number ) => void ;
2223}
2324
2425const Swiper = ( {
@@ -37,6 +38,7 @@ const Swiper = ({
3738 keyExtractor,
3839 renderItem,
3940 children,
41+ onIndexChanged,
4042 style,
4143} : SwiperProps < any > ) => (
4244 < View style = { style } >
@@ -46,6 +48,7 @@ const Swiper = ({
4648 loop = { loop }
4749 timeout = { timeout }
4850 vertical = { vertical }
51+ onIndexChanged = { onIndexChanged }
4952 controlsProps = { {
5053 prevTitle,
5154 nextTitle,
Original file line number Diff line number Diff line change 55 createTextProp ,
66 createColorProp ,
77 GROUPS ,
8+ Triggers ,
9+ createActionProp ,
810} from "@draftbit/types" ;
911
1012export const SEED_DATA = {
@@ -16,7 +18,9 @@ export const SEED_DATA = {
1618 height : 300 ,
1719 width : "100%" ,
1820 } ,
21+ triggers : [ Triggers . OnIndexChanged ] ,
1922 props : {
23+ onIndexChanged : createActionProp ( ) ,
2024 from : createNumberProp ( {
2125 group : GROUPS . basic ,
2226 label : "Initial Slide" ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export const Triggers = {
1414 OnCheck : "ON_CHECK" ,
1515 OnUncheck : "ON_UNCHECK" ,
1616 OnPressIcon : "ON_PRESS_ICON" ,
17+ OnIndexChanged : "ON_INDEX_CHANGED" ,
1718 OnEndReached : "ON_END_REACHED" ,
1819} ;
1920
You can’t perform that action at this time.
0 commit comments