npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-swiper-flatlist

v3.2.3

Published

React native swiper flatlist component

Downloads

60,167

Readme

:point_up_2: Swiper FlatList component

supports iOS supports Android supports web npm npm Build Status license

Demo

Installation

yarn add react-native-swiper-flatlist

or

npm install react-native-swiper-flatlist --save

Notice

Version 2.x was re-implemented using React Hooks so it only works with version 0.59 or above

Version 3.x was re-implemented using Typescript and it works with react-native-web

| react-native-swiper-flatlist | react-native | Detox tests | | ---------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 1.x | <= 0.58 | X | | 2.x | >= 0.59 | X | | 3.x | >= 0.59 | Build Status |

Note: we are using the feature export type available in babel v7.9.0 https://github.com/babel/babel/pull/11171, you might have this issue with React Native between 0.60 and 0.63, please update babel to at least to v7.9.0

Examples

Expo example with renderItems, children and more

Expo example with children

React Native example with renderItems and custom pagination

React Native example with children

Code

Using renderItems and data run in expo snack

import React from 'react';
import { Text, Dimensions, StyleSheet, View } from 'react-native';
import { SwiperFlatList } from 'react-native-swiper-flatlist';

const colors = ['tomato', 'thistle', 'skyblue', 'teal'];

const App = () => (
  <View style={styles.container}>
    <SwiperFlatList
      autoplay
      autoplayDelay={2}
      autoplayLoop
      index={2}
      showPagination
      data={colors}
      renderItem={({ item }) => (
        <View style={[styles.child, { backgroundColor: item }]}>
          <Text style={styles.text}>{item}</Text>
        </View>
      )}
    />
  </View>
);

const { width } = Dimensions.get('window');
const styles = StyleSheet.create({
  container: { flex: 1, backgroundColor: 'white' },
  child: { width, justifyContent: 'center' },
  text: { fontSize: width * 0.5, textAlign: 'center' },
});

export default App;

Using children run in expo snack

import React from 'react';
import { Text, Dimensions, StyleSheet, View } from 'react-native';
import { SwiperFlatList } from 'react-native-swiper-flatlist';

const App = () => (
  <View style={styles.container}>
    <SwiperFlatList autoplay autoplayDelay={2} autoplayLoop index={2} showPagination>
      <View style={[styles.child, { backgroundColor: 'tomato' }]}>
        <Text style={styles.text}>1</Text>
      </View>
      <View style={[styles.child, { backgroundColor: 'thistle' }]}>
        <Text style={styles.text}>2</Text>
      </View>
      <View style={[styles.child, { backgroundColor: 'skyblue' }]}>
        <Text style={styles.text}>3</Text>
      </View>
      <View style={[styles.child, { backgroundColor: 'teal' }]}>
        <Text style={styles.text}>4</Text>
      </View>
    </SwiperFlatList>
  </View>
);

const { width } = Dimensions.get('window');

const styles = StyleSheet.create({
  container: { flex: 1, backgroundColor: 'white' },
  child: { width, justifyContent: 'center' },
  text: { fontSize: width * 0.5, textAlign: 'center' },
});

export default App;

Example project with Detox tests

Code example

To use react-native-gesture-handler instead of FlatList import the library like:

import { SwiperFlatListWithGestureHandler } from 'react-native-swiper-flatlist/WithGestureHandler';

Props

| Prop | Default | Type | Description | | :-------------------------- | :------------------------------------------------: | :-------------------------------------: | :------------------------------------------------------------------------------------ | | data | not required if children is used | array | Data to use in renderItem | | children | - | node | Children elements | | renderItem | not required if children is used | FlatListProps<T>['renderItem'] | Takes an item from data and renders it into the list | | onMomentumScrollEnd | - | (item: { index: number }, event: any) | Called after scroll end and the first parameter is the current index | | vertical | false | boolean | Show vertical swiper | | index | 0 | number | Index to start | | renderAll | false | boolean | Render all the items before display it | | Pagination | | showPagination | false | boolean | Show pagination | | paginationDefaultColor | gray | string | Pagination color | | paginationActiveColor | white | string | Pagination color | | paginationStyle | {} | ViewStyle | Style object for the container | | paginationStyleItem | {} | ViewStyle | Style object for the item (dot) | | paginationStyleItemActive | {} | ViewStyle | Style object for the active item (dot) | | paginationStyleItemInactive | {} | ViewStyle | Style object for the inactive item (dot) | | onPaginationSelectedIndex | - | () => void | Executed when the user presses the pagination index, similar properties onChangeIndex | | PaginationComponent | Component | node | Overwrite Pagination component | | Autoplay | | autoplay | false | boolean | Change index automatically | | autoplayDelay | 3 | number | Delay between every page in seconds | | autoplayLoop | false | boolean | Continue playing after reach end | | autoplayLoopKeepAnimation | false | boolean | Show animation when reach the end of the list | | autoplayInvertDirection | false | boolean | Invert auto play direction | | disableGesture | false | boolean | Disable swipe gesture |

More props

This is a wrapper around Flatlist, all their props works well and the inherited props too (from ScrollView and VirtualizedList)

Functions

| Name | Type | Use | | :-------------- | :----------------------------------------------- | :-------------------------------------------------------------------------------------------------- | | scrollToIndex | ({ index: number, animated?: boolean}) => void | Scroll to the index | | getCurrentIndex | () => number | Returns the current index | | getPrevIndex | () => number | Returns the previous index | | onChangeIndex | ({ index: number, prevIndex: number}) => void | Executed every time the index change, the index change when the user reaches 60% of the next screen | | goToFirstIndex | () => void | Go to the first index | | goToLastIndex | () => void | Go to the last index |

Right To Left

This library support RTL languages, when I18nManager.isRTL is true.

Limitations

  • Vertical pagination is not supported on Android. Doc, that is way we have useReactNativeGestureHandler which is a workaround for this issue.

Author

Gustavo Gard