react-native-momentum-carousel
Version:
A React Native carousel component enables smooth and interactive image or content sliders with swiping capabilities. Ideal for showcasing multiple items or images in a compact space, this carousel can be customized with features like infinite scrolling, p
63 lines • 3.13 kB
TypeScript
import React, { PropsWithoutRef, RefAttributes } from 'react';
import { ListRenderItem, FlatListProps, StyleProp, ViewStyle } from 'react-native';
/**
* CarouselProps defines the expected properties for the CarouselMomentum component.
* - `data`: Array of items to display in the carousel.
* - `sliderWidth`: The width of the carousel container.
* - `itemWidth`: The width of each individual item in the carousel.
* - `renderItem`: Function that renders each item in the carousel.
* - `keyExtractor`: Function that provides a unique key for each item, defaulting to index if not provided.
* - `onSnap`: Callback that is triggered when an item is snapped to the center of the carousel.
* - `accessibilityLabelCarousel`: Optional accessibility label for the carousel.
* - `onMomentumScrollBegin`: Optional Callback triggered when momentum scrolling starts.
* - `onMomentumScrollEnd`: Optional Callback triggered when momentum scrolling ends.
* - `autoPlay`: Optional boolean to enable automatic scrolling through the carousel.
* - `loop`: Optional boolean to loop the carousel back to the start after reaching the last item.
* - `autoPlayInterval`: Optional number for automatic scrolling through the carousel.
* - `inactiveScale`: Optional number for scale inactive items
* - `showPagination`: Optional boolean to show pagination component.
* - `paginationStyle`: Optional style for pagination component {container:{},bullet:{},activeBullet:{}}.
* - `animation`: CarouselMomentumAnimationType Enum to choose the suitable animation.
* - `customAnimation`: Optional boolean to avoid default animation.
*/
interface CarouselProps<Item> extends Pick<FlatListProps<Item>, 'onEndReached' | 'onEndReachedThreshold' | 'onContentSizeChange' | 'onLayout' | 'onRefresh' | 'onViewableItemsChanged'> {
carouselStyle?: StyleProp<ViewStyle>;
itemStyle?: StyleProp<ViewStyle>;
data: Item[];
sliderWidth?: number;
itemWidth?: number;
vertical?: boolean;
sliderHeight?: number;
itemHeight?: number;
renderItem: ListRenderItem<Item>;
keyExtractor?: (item: Item, index: number) => string;
onSnap: (index: number) => void;
accessibilityLabelCarousel?: string;
onMomentumScrollBegin?: () => void;
onMomentumScrollEnd?: () => void;
autoPlay?: boolean;
loop?: boolean;
autoPlayInterval?: number;
inactiveScale?: number;
showPagination?: boolean;
paginationStyle?: {
container?: StyleProp<ViewStyle>;
bullet?: StyleProp<ViewStyle>;
activeBullet?: StyleProp<ViewStyle>;
};
animation: CarouselMomentumAnimationType;
customAnimation?: boolean;
}
export interface CarouselRef {
getCurrentIndex: () => number;
goToIndex: (index: number) => void;
}
export declare enum CarouselMomentumAnimationType {
Default = 0,
Stack = 1,
Tinder = 2
}
declare const _default: GenericForwardRefExoticComponent;
export default _default;
type GenericForwardRefExoticComponent = <Item>(props: PropsWithoutRef<CarouselProps<Item>> & RefAttributes<CarouselRef>) => React.ReactNode;
//# sourceMappingURL=CarouselMomentum.d.ts.map