Git Product home page Git Product logo

react-native-viewpager's Introduction

react-native-viewpager

npm version npm downloads

This is the ViewPager componnent in React Native both for Android and iOS. This is a JavaScript-only implementation of pager for React Native. Like ListView, this can render hundreds of pages without performance issue. Better than the one in Android, this ViewPager can auto play -- turn page automaticly, loop -- make infinite scrolling.

Demo

Demo project is here.

Usage

  1. Run npm install react-native-viewpager --save
  2. Code like this:
var ViewPager = require('react-native-viewpager');
<ViewPager
    dataSource={this.state.dataSource}
    renderPage={this._renderPage}/>

More configuration

  • dataSource: this is require to provide pages data,
  • renderPage: this is require to render page view,
  • autoPlay: true to turn page automatically,
  • isLoop: true to run in infinite scroll mode,
  • locked: true to disable touch scroll,
  • onChangePage: page change callback,
  • renderPageIndicator: render custom ViewPager indicator.
  • initialPage: show initially some other page than first page.

Page Transition Animation Controls

  • animation: function that returns a React Native Animated configuration.

Example:

var ViewPager = require('react-native-viewpager');
<ViewPager
    dataSource={this.state.dataSource}
    renderPage={this._renderPage}
    animation = {(animatedValue, toValue, gestureState) => {
    // Use the horizontal velocity of the swipe gesture
    // to affect the length of the transition so the faster you swipe
    // the faster the pages will transition
    var velocity = Math.abs(gestureState.vx);
    var baseDuration = 300;
    var duration = (velocity > 1) ? 1/velocity * baseDuration : baseDuration;

    return Animated.timing(animatedValue,
    {
      toValue: toValue,
      duration: duration,
      easing: Easing.out(Easing.exp)
    });
  }}
/>

Licensed

MIT License

react-native-viewpager's People

Contributors

race604 avatar christopherabouabdo avatar yychun1217 avatar fmcorz avatar hufeng avatar jihopark avatar everfire130 avatar cornedor avatar tristola avatar timzaak avatar

Watchers

James Cloos avatar kevin chen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.