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-swiper3

v2.0.6

Published

Swiper component for React Native. Supersede react-native-swiper

Downloads

11

Readme

react-native-swiper2

npm version

logo

Based on react-native-swiper2, which was the best Swiper component for React Native.

However for some reason, react-native-swiper didn't update for long time, and can not run on recent react native versions.

fix some bugs On android

So I forked this react-native-swiper2, and would maintain it as long as I could.

PRs or Issues are deeply welcomed.

Changelogs

  • [v2.0.6]

    • surport dynamic generated children
  • [v2.0.5]

  • [v2.0.4]

    • fix scrollTo warning.
  • [v2.0.3]

    • support pagination on android.
  • [v2.0.2]

    • add simple support for android.
  • [v2.0.1]

    • fix the dimensions module error.
    • fix the keys warning when render dots.
  • [v1.3.0]

  • [v1.2.2]

    • 890c0ce ensure onMomentumScrollEnd synchronous update index.
  • [v1.2.0]

    • 838b24c Re-design a loop model for avoid img flickering.
    • 9cb91c5 fixes #7 onMomentumScrollEnd lost event param. (thanks @smothers)
  • [v1.1.1]

  • [v1.1.0]

  • [v1.0.4]

  • [v1.0.3]

Show Cases

Try these cases by yourself very easy, Just open examples/swiper.xcodeproj with Xcode, then press Cmd + R; you may edit examples/index.ios.js for switch cases.

examples/basic.js

![](http://i.imgur.com/zrsazAG.gif =300x)

examples/swiper.js

![](http://i.imgur.com/hP3f3oO.gif =300x)

examples/swiper_number.js

![](http://i.imgur.com/0rqESVb.gif =300x)

examples/phone.js

![](http://i.imgur.com/c1BhjZm.gif =300x)

Getting Started

Installation

$ npm i react-native-swiper2 --save

Basic Usage

  • Install react-native-cli first
$ npm i react-native-cli -g
  • Initialization of a react-native project
$ react-native init myproject
  • Then, edit myproject/index.ios.js, like this:
var Swiper = require('react-native-swiper2')
// es6
// import Swiper from 'react-native-swiper2'

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} = React;

var styles = StyleSheet.create({
  wrapper: {
  },
  slide1: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#9DD6EB',
  },
  slide2: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#97CAE5',
  },
  slide3: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#92BBD9',
  },
  text: {
    color: '#fff',
    fontSize: 30,
    fontWeight: 'bold',
  }
})

var swiper = React.createClass({
  render: function() {
    return (
      <Swiper style={styles.wrapper} showsButtons={true}>
        <View style={styles.slide1}>
          <Text style={styles.text}>Hello Swiper</Text>
        </View>
        <View style={styles.slide2}>
          <Text style={styles.text}>Beautiful</Text>
        </View>
        <View style={styles.slide3}>
          <Text style={styles.text}>And simple</Text>
        </View>
      </Swiper>
    )
  }
})

AppRegistry.registerComponent('swiper', () => swiper)

Properties

Basic

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | horizontal | true | bool | If true, the scroll view's children are arranged horizontally in a row instead of vertically in a column. | | loop | true | bool | Set to true to enable continuous loop mode. | | index | 0 | number | Index number of initial slide. | | showsButtons | false | bool | Set to true make control buttons visible. | | autoplay | false | bool | Set to true enable auto play mode. |

Custom basic style & content

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | width | - | number | If no specify default enable fullscreen mode by flex: 1. | | height | - | number | If no specify default fullscreen mode by flex: 1. | | style | {...} | style | See default style in source. |

Pagination

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | showsPagination | true | bool | Set to true make pagination visible. | | paginationStyle | {...} | style | Custom styles will merge with the default styles. | | renderPagination | - | function | Complete control how to render pagination with three params (index, total, context) ref to this.state.index / this.state.total / this, For example: show numbers instead of dots. | | dot | <View style={{backgroundColor:'rgba(0,0,0,.2)', width: 8, height: 8,borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> | element | Allow custom the dot element. | | activeDot | <View style={{backgroundColor: '#007aff', width: 8, height: 8, borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> | element | Allow custom the active-dot element. |

Autoplay

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | autoplay | true | bool | Set to true enable auto play mode. | | autoplayTimeout | 2.5 | number | Delay between auto play transitions (in second). | | autoplayDirection | true | bool | Cycle direction control. |

Control buttons

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | showsButtons | true | bool | Set to true make control buttons visible. | | buttonWrapperStyle | {backgroundColor: 'transparent', flexDirection: 'row', position: 'absolute', top: 0, left: 0, flex: 1, paddingHorizontal: 10, paddingVertical: 10, justifyContent: 'space-between', alignItems: 'center'} | style | Custom styles. | | nextButton | <Text style={styles.buttonText}>›</Text> | element | Allow custom the next button. | | prevButton | <Text style={styles.buttonText}>‹</Text> | element | Allow custom the prev button. |

Props of Children

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | style | {...} | style | Custom styles will merge with the default styles. | | title | {...} | element | If this parameter is not specified, will not render the title. |

Basic props of <ScrollView />

| Prop | Default | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | horizontal | true | bool | If true, the scroll view's children are arranged horizontally in a row instead of vertically in a column. | | pagingEnabled | true | bool | If true, the scroll view stops on multiples of the scroll view's size when scrolling. This can be used for horizontal pagination. | | showsHorizontalScrollIndicator | false | bool | Set to true if you want to show horizontal scroll bar. | | showsVerticalScrollIndicator | false | bool | Set to true if you want to show vertical scroll bar. | | bounces | false | bool | If true, the scroll view bounces when it reaches the end of the content if the content is larger then the scroll view along the axis of the scroll direction. If false, it disables all bouncing even if the alwaysBounce* props are true. | | scrollsToTop | false | bool | If true, the scroll view scrolls to top when the status bar is tapped. | | removeClippedSubviews | true | bool | If true, offscreen child views (whose overflow value is hidden) are removed from their native backing superview when offscreen. This canimprove scrolling performance on long lists. | | automaticallyAdjustContentInsets | false | bool | Set to true if you need adjust content insets automation. |

@see: http://facebook.github.io/react-native/docs/scrollview.html

Supported ScrollResponder

| Prop | Params | Type | Description | | :------------ |:---------------:| :---------------:| :-----| | onMomentumScrollBegin | e / state / context | function | When animation begins after letting up | | onMomentumScrollEnd | e / state / context | function | Makes no sense why this occurs first during bounce | | onTouchStartCapture | e / state / context | function | Immediately after onMomentumScrollEnd | | onTouchStart | e / state / context | function | Same, but bubble phase | | onTouchEnd | e / state / context | function | You could hold the touch start for a long time | | onResponderRelease | e / state / context | function | When lifting up - you could pause forever before * lifting |

Note: each ScrollResponder be injected with two params: state and context, you can get state and context(ref to swiper's this) from params, for example:

var swiper = React.createClass({
  _onMomentumScrollEnd: function (e, state, context) {
    console.log(state, context.state)
  },
  render: function() {
    return (
      <Swiper style={styles.wrapper}
      onMomentumScrollEnd ={this._onMomentumScrollEnd}
     ...
      </Swiper>
    )
  }
})

More ScrollResponder info, see: https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollResponder.js

Examples

@TODO, see code in examples first.

Development

$ npm start

Contribution

  • @leecade The main author of the original version .

Questions

Feel free to create an issue

Inspired by nolimits4web/Swiper & Design material from Dribbble & made with ♥.