UNPKG

react-native-rtl-ltr-swiper

Version:
17 lines (16 loc) 822 B
import React from 'react'; import { FlatList, I18nManager, View, } from 'react-native'; export function Swiper({ data, renderItem, itemWidth = 300, containerStyle, flatListProps = {}, }) { return (<View style={[ { flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row' }, containerStyle, ]}> <FlatList data={data} horizontal renderItem={renderItem} keyExtractor={(_, index) => index.toString()} showsHorizontalScrollIndicator={false} contentContainerStyle={{ flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row', }} getItemLayout={(data, index) => ({ length: itemWidth, offset: itemWidth * index, index, })} snapToInterval={itemWidth} decelerationRate="fast" pagingEnabled {...flatListProps}/> </View>); }