Carousel
Carousel for scrolling pages
(code example)
This component extends ScrollView props.
This component support **** modifiers.
Usageβ
function Example(props) { const BACKGROUND_COLORS = [ Colors.red50, Colors.yellow20, Colors.purple50, Colors.green50, Colors.cyan50, Colors.purple20, Colors.blue60, Colors.red10, Colors.green20, Colors.purple60 ]; const Page = ({children, style, ...others}) => { return ( <View {...others} style={[{flex: 1, borderWidth: 1, borderRadius: 8}, style]}> {children} </View> ); }; return ( <div> <View style={{width: 800}}> <Carousel autoplay // onChangePage={onChangePage} pageWidth={800 - Spacings.s5 * 2} itemSpacings={Spacings.s3} containerMarginHorizontal={Spacings.s2} initialPage={2} containerStyle={{height: 160}} pageControlPosition={Carousel.pageControlPositions.UNDER} // allowAccessibleLayout > {_.map([...Array(10)], (_item, index) => ( <Page style={{backgroundColor: BACKGROUND_COLORS[index]}} key={index}> <Text margin-15>CARD {index}</Text> </Page> ))} </Carousel> </View> </div> ); }
APIβ
allowAccessibleLayoutβ
Whether to layout Carousel for accessibility
boolean
animatedβ
Should the container be animated (send the animation style via containerStyle)
boolean
animatedScrollOffsetβ
Pass to attach to ScrollView's Animated.event in order to animated elements base on Carousel scroll offset (pass new Animated.ValueXY())
Animated.ValueXY
autoplayβ
Enable to switch automatically between the pages
boolean
autoplayIntervalβ
Time is ms to wait before switching to the next page (requires 'autoplay' to be enabled)
number
containerMarginHorizontalβ
Horizontal margin for the carousel container
number
containerPaddingVerticalβ
Vertical padding for the carousel container (Sometimes needed when there are overflows that are cut in Android).
number
containerStyleβ
The carousel container style
ViewStyle
counterTextStyleβ
The counter's text style
ViewStyle
horizontalβ
Whether pages will be rendered horizontally or vertically
boolean
initialPageβ
The initial page to start at
number
itemSpacingsβ
The spacing between the pages
number
loopβ
If true, will have infinite scroll (works only for horizontal carousel)
boolean
onChangePageβ
Callback for page change event
(pageIndex, oldPageIndex, info) => void
onScrollβ
Attach a callback for onScroll event of the internal ScrollView
function
pageControlPositionβ
The position of the PageControl component ['over', 'under'], otherwise it won't display
PageControlPosition
pageControlPropsβ
PageControl component props
PageControlProps
pageHeightβ
The page height (all pages should have the same height).
number
pageWidthβ
The page width (all pages should have the same width). Does not work if passing 'loop' prop
number
pagingEnabledβ
Will block multiple pages scroll (will not work with 'pageWidth' prop)
boolean
showCounterβ
Whether to show a page counter (will not work with 'pageWidth' prop)
boolean