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 (59 loc) • 2.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
var _useLayoutConfig = require("./useLayoutConfig");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// ItemCarouselProps defines the properties for each item in the carousel.
// These props are used to configure the appearance and behavior of the carousel items.
// 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 = (0, _useLayoutConfig.useLayoutConfig)(data);
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.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
var _default = exports.default = ItemCarousel;
//# sourceMappingURL=ItemCarousel.js.map