UNPKG

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

58 lines (54 loc) 1.77 kB
"use strict"; import React from 'react'; import Animated from 'react-native-reanimated'; import { useLayoutConfig } from './useLayoutConfig'; // ItemCarouselProps defines the properties for each item in the carousel. // These props are used to configure the appearance and behavior of the carousel items. import { jsx as _jsx } from "react/jsx-runtime"; // ItemCarousel component renders each item in the carousel. // It applies the necessary styles and animations based on the scroll position. const ItemCarousel = ({ getHandleItemInternalRef, itemWidth, itemStyle, renderItem, info, scrollX, inactiveScale, animation, itemHeight, vertical, customAnimation }) => { // Collect all the necessary props into a data object to be used for layout configuration const data = { getHandleItemInternalRef, itemWidth, itemStyle, renderItem, info, scrollX, inactiveScale, animation, itemHeight, vertical }; // Use the layout configuration hook to calculate animation and layout properties for each item const layoutConfig = useLayoutConfig(data); return /*#__PURE__*/_jsx(Animated.View, { // Set a reference for the current item using the index to manage accessibility ref: getHandleItemInternalRef(info.index), style: [{ width: itemWidth, // Set the width of the item height: itemHeight // Set the height of the item }, // If customAnimation is not set, apply the layoutConfig (animations and styles) !customAnimation ? layoutConfig : {}, itemStyle // Apply the optional item style ], children: renderItem(info) }); }; // Export the ItemCarousel component as the default export export default ItemCarousel; //# sourceMappingURL=ItemCarousel.js.map