3.1.1 • Published 2 years ago

react-native-infinite-swiper v3.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

React Native Infinite Swiper

MIT License GitHub last commit

React Native package that wraps react-native-pager-view and adds the following features:

  • Loop
  • Zoom

Getting started

Requirements

react-native-pager-view

react-native-pager-view is a peer dependency for this package that you'll need to add to your project.

react-native-modal

react-native-modal is a peer dependency that will be required if you enable zoom.

To install these dependencies run the following command:

yarn add react-native-pager-view react-native-modal

or

npm install react-native-pager-view react-native-modal

Install

yarn add react-native-infinite-swiper

or

npm install react-native-infinite-swiper

Usage

import React from 'react'
import {StyleSheet, View, Text} from 'react-native'
import Paging from 'react-native-infinite-swiper'

const MyPager = () => {
  return (
    <Paging 
      style={styles.viewPager} 
      loop
      zoom
    >
      <View key="1">
        <Text>First page</Text>
      </View>
      <View key="2">
        <Text>Second page</Text>
      </View>
    </Paging>
  )
}

export default MyPager

const styles = StyleSheet.create({
  viewPager: {
    flex: 1,
  },
})

API

NameTypeDefaultDescription
widthnumberSets width of rendered child
heightnumberSets height of rendered child
onIndexChangedState setterUpdates state with new index when user swipes
loopboolfalseLoops infinitely when reaching the last slide
zoomboolfalseOpens a modal with the slide when pressed
childrenelementAccepts all the children elements to be rendered
orientationOrientationhorizontalSet horizontal or vertical scrolling orientation

Roadmap

  • Explore possibility to remove dependency from react-native-pager-view and use own pager view solution.
  • Add support for custom icon for closing the zoom modal.
  • Add support for custom props for the zoom modal component.

Contributing

Pull requests are welcome! Feel free to open issues and submit PRs, we will review them and answer back as fast as possible.

🚀 Authors