AutoLoopCarousel
Reusable AutoLoopCarousel component
Example
import {
AutoLoopCarousel,
createStyles,
rem,
Typography,
useStyles,
View,
} from '@lad-tech/mobydick-core';
const data: number[] = [1, 2, 3, 4, 5, 6];
const ITEM_WIDTH = rem(80);
export const LoopCarouselWidget = () => {
const [styles] = useStyles(stylesFn);
return (
<AutoLoopCarousel
data={data}
sliderItem={item => (
<View style={[styles.blockView, {width: ITEM_WIDTH}]}>
<Typography>{item}</Typography>
</View>
)}
itemWidth={ITEM_WIDTH}
sideMargin={2}
/>
);
};
const stylesFn = createStyles(({spaces, colors}) => ({
container: {
gap: spaces.Space16,
},
blockView: {
backgroundColor: colors.BgAccent,
aspectRatio: 1,
alignItems: 'center',
justifyContent: 'center',
},
}));
Props
FlatList Props
Inherits FlatList Props.
Requireddata
TYPE |
---|
ArrayLike |
Data for Carousel
RequiredsliderItem
TYPE |
---|
(item: T, index: number, data: ArrayLike) => ReactElement |
RequireditemWidth
TYPE |
---|
number |
sideMargin
TYPE | DEFAULT |
---|---|
number | 10 |
Margin for items