rn-fast-swiper
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

React Native Fast Swiper

Downloads Version


Preview

Screen-Recording-2024-08-09-at-16 24 52

Screen-Recording-2024-08-09-at-16 26 00

Installation

Type in the following to the command line to install the module.


$ npm install --save rn-fast-swiper

or

$ yarn add rn-fast-swiper



Usage

import RNFastSwiper from 'react-native-flat-swiper';
import { View, Image, StyleSheet } from 'react-native';
import React, { useRef } from 'react';

const SomeComponent = () => {

  const rnFastSwiperRef = useRef(null);

  const onSwipeIndexChange = (index: number) => {
    // get the index of the card when on swiping
  };

  //Trigger to next card by ref:
  rnFastSwiperRef?.current?.scrollBy(1, false);  //scrollBy(cardIndex: number, animation: boolean)

  //Trigger to any card by ref with index:
  rnFastSwiperRef?.current?.scrollTo(yourCardIndex, false); //scrollTo(cardIndex: number, animation: boolean)

return (
   <RNFastSwiper
	index={0}
	loop={false}
	ref={rnFastSwiperRef}
	horizontal={false}
	loadMinimal={true}
	data={yourData[] || []}
	enableAndroidViewPager={false}
	onIndexChangeReached={(index) => onSwipeIndexChange(index)}
	renderItem={({ item, index }) => {
	   //IMPORTANT: props name "item" is required
	   return (
		<View key={index} style={styles.item}>
			<Text>View {index}</Text>
		</View>
	   );
	}}
   />
);
};

const styles = StyleSheet.create({
  item: { flex: 1}  // to display 1 item per time
})

Package Sidebar

Install

npm i rn-fast-swiper

Weekly Downloads

5

Version

1.0.2

License

MIT

Unpacked Size

24.7 kB

Total Files

4

Last publish

Collaborators

  • lavisar