Giter Club home page Giter Club logo

react-native-swiper's Introduction

react-native-swiper

The best Swiper component for React Native.

JavaScript Style Guide npm version npm version PR Stats Issue Stats Join the chat

react-native-swiper

Roadmap

see: ROADMAP.md

Changelogs

  • [1.6.0-rc]
    • Dependency
      • Remove ViewPagerAndroid, use ScrollView #1009
    • Test Integration
      • Setup e2e test
    • TypeScript
      • correct the wrong types #1000
      • Add missing scrollBy TypeScript definition #931
    • New Feature
      • add scrollTo #831
      • Added prop to disable the PrevButton #749
      • Optionally render page #1004
    • Bug Fix
      • ES6 and CommonJS compatibility #717
      • Solves the issue of state messing up when parent component calls setState #939
      • replay when autoplay is setted to true #1002
      • fix broken examples and migrate to react-native 0.60.x
      • fix bad jumping on ios when loadMinimal set true
      • fix fliker when loop and loadMinimal are enabled #1062
  • [1.5.6]

  • [1.5.5]

    • Update: using PropTypes from prop-types and Change View.propTypes to ViewPropTypes
  • [1.5.4]

    • Added easily accessible pagination point manipulation: use dotColor / activeDotColor and dotStyle / activeDotStyle (thanks @denizs)
    • Added scrollEnabled prop to documentation (thanks @ibandominguez)
  • [1.5.3]

    • Add loadMinimalLoader prop to customize <ActivityIndicator /> (thanks @Exilz)
    • Disable autoplay timer when prop changes to false (thanks @dizlexik)
    • Special thanks to @hypatiah for fixed some grammatical errors in README
  • [1.5.2]

    • Add yarn lock
    • Fix jitter when quickly swiping back and forth between pages (iOS) (thanks @nemophrost)
    • The first webview always reloaded when injecting the rest of the children (thanks @eosterberg)

see more: CHANGELOG.md

Show Cases

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

Getting Started

Installation

v1.5.14

$ npm i react-native-swiper --save

v1.6.0-rc

npm i --save react-native-swiper@next

Basic Usage

  • Install react-native 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:
import React, { Component } from 'react'
import { AppRegistry, StyleSheet, Text, View } from 'react-native'

import Swiper from 'react-native-swiper'

const 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'
  }
})

export default class SwiperComponent extends Component {
  render() {
    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('myproject', () => SwiperComponent)

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 false to disable 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.
onIndexChanged (index) => null func Called with the new index when the user swiped

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.
containerStyle {...} style See default container style in source.
loadMinimal false bool Only load current index slide , loadMinimalSize slides before and after.
loadMinimalSize 1 number see loadMinimal
loadMinimalLoader <ActivityIndicator /> element Custom loader to display when slides aren't loaded

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.
dotStyle - object Allow custom the dot element.
dotColor - string Allow custom the dot element.
activeDotColor - string Allow custom the active-dot element.
activeDotStyle - object 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.
scrollEnabled true bool Enables/Disables swiping

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

Supported ScrollResponder

Prop Params Type Description
onScrollBeginDrag 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

Methods

scrollBy(index, animated)

Scroll by relative index.

Parameters:

Name Type default Description
index number undefined offset index
animated bool true offset index

Examples

$ cd examples
$ npm i
$ react-native run-ios

Quick start with examples.

Development

$ cd examples
$ yarn
$ yarn start
$ react-native run-ios

Then launch simulator to preview. Note that you just need to edit the source file src/index.js, the change will auto sync to examples.

After development, you should add test for your modification and make all tests passed to prevent other contributors break the feature in the future accidentally. We use detox + jest for e2e test now, you can read Detox for more detail.

Contribution

Questions

Feel free to contact me or create an issue

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

react-native-swiper's People

Contributors

ahmed3mar avatar alattanzio avatar andrewthoughtmachine avatar arrayzoneyour avatar brendan-rius avatar brianantonelli avatar brianreavis avatar dependabot[bot] avatar eric013 avatar exilz avatar flyskywhy avatar fungilation avatar germanst avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hypatiah avatar jasonmerino avatar leecade avatar maffoobristol avatar movibe avatar mrdezzods avatar nemophrost avatar nixoz avatar onchainguy-eth avatar petermiles avatar rajkissu avatar samparmenter avatar sunnylqm avatar tezqa avatar wcandillon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-swiper's Issues

Auto play issue when only a child view

Your code in autoplay function:

if (!this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) {
  return;
}

should be:

if (!Array.isArray(this.props.children) || !this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) {
  return;
}

or the child view will fly away.

Tiny docs update

Hey, I think that given the loop attribute is true by default, the docs should say

Set to false to disable continuous loop mode.

instead of

Set to true to enable continuous loop mode.

:)

WebView scrolls up, sometimes

Hello.

When swiping between a few WebViews, the non focused webview scrolls up to top and flicks back to the last scroll positions shortly after the slide gets in position.
This happens about 50% of the time. And only if I swipe between more than two WebView slides.
(Have only tried this in iOS Simulator)

scroll has a little problem

I use swiper and inside embedded a ListView, when I first upwards sliding ListView, no problem, but before the end of the sliding effect no I loosen the fingers, sliding again, ListView can't slide, can only wait for it to stop, to continue to slide, not straight, I do not have this problem using a ListView alone, how to solve?

Dynamic slides are breaking app in some cases

When using single app state and keeping currentSlideItem in a store, every time we update them, the componentWillReceiveProps re-renders the whole slider resetting the index. It makes sliding impossible. I believe there should be one extra check to ensure the children are different and reset only if that happens. Maybe shallowEqual on the array + support for Immutable list can do the trick?

Installation gives ENOENT for Babel

I get the following error when running npm install react-native-swiper --save:

$ npm install react-native-swiper --save
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/nvm/versions/node/v0.12.2/bin/npm" "install" "react-native-swiper" "--save" "--production"
npm ERR! node v0.12.2
npm ERR! npm  v2.8.3
npm ERR! path /Users/jwaples/Repositories/Lemmeno/LemmenoNative/node_modules/react-native-swiper/bin/babel
npm ERR! code ENOENT
npm ERR! errno -2

npm ERR! enoent ENOENT, chmod '/Users/jwaples/Repositories/Lemmeno/LemmenoNative/node_modules/react-native-swiper/bin/babel'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/jwaples/Repositories/Lemmeno/LemmenoNative/npm-debug.log

This occurs both with Node 0.12.2 and Node 0.10.36, with or without the --production flag to NPM.

Git repo is ahead of npm module and non-functional

Please correct me if I'm wrong, but it appears that a recent commit has made the swiper non-functional. The npm module is dated '5 months ago', but there are a number of commits past that on the master github branch. My slides just stack vertically instead of being swipeable. Is it possible or reasonable to move recent commits to a branch and sync the master branch with what's on npm?

Unable to resolve module Dimensions from

Hello,

I get the following warning in the packager:

Unable to resolve module Dimensions from .... dist.js

Any idea how to fix that? Everything is working correctly, just the message in the packager.

Regards

ScrollResponders are not supported

ScrollResponders are documented in the readme, but onMomentumScrollEnd along with the other responders throw invalid property errors when added to a Swiper.

Landscape mode

Great module! Any pointers on how to get it working when changing the device orientation to landscape?

Show numbers instead of dots?

Great component! It would be good to have X/Y (X current page / Y total pages) customizable label string instead of dots for big lists.

Xcode 7.0 command and /bin/sh failed with exit code 1

When I require swiper in my index.ios.js,the project occupy run failed.but when i download the examples and run it. it success I'm confuse about this,whether I should require other modules? It's very thankful if you can response me and help me clear what happen.
ar Swiper = require('react-native-swiper')
// es6
// import Swiper from 'react-native-swiper'

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 (


Hello Swiper


Beautiful


And simple


)
}
})

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

Issue rendering dynamic data, stacked 'slides'

The swiper is working great for us when we create slides that contain static stuff:

i.e.
< swiper >
< view >stuff< /view >
< view >stuff< /view >
< view >stuff< /view >
< /swiper >

However, when we loop in dynamic content for the list of interior views like so:

< swiper >
{ slideLoop }
< /swiper >

all of the views render vertically stacked within the first 'slide', instead of each displaying as a slide as you'd expect. Has anyone experienced issues like this?

Thanks

Changing height due to statusbar change

Hi,

I'm currently facing the issue that I try to update the height of the swiper dynamically when the status bar height changes e.g. due to tethering etc. However, I dont really know how to give the new height to the swiper element as it seems to set the props in the getInitialState

Any idea?

Regards
Philipp

Display parts of previous and next slides/pages

Is it possible to use this component to display parts of the previous and next slides in the carousel, without changing the source? I.e. have the current page in the center and show a couple of pixels of the previous slide to the left and couple of pixels of the next slide to the right?

Warning in console about key prop for pagination

I noticed that the code that generates the dots is looping without a key prop on the component which leads to this warning, no biggie just thought I would share.

"Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of index. It was passed a child from SignDetail. See http://fb.me/react-warning-keys for more information."

Index not updating

Hello.

I've bound onMomentumScrollEnd and there I'm console logging the ref to my Swiper.
The state.index is always set to 0.

Is that a bug or is there another way to find out which node is viewed?

Doesn't fit inside container unless width/height are hard-coded

I'd like the Swiper to take up the full size of its parent View element. Approaches:

  1. If I don't specify width and height attributes, the Swiper element extends outside the parent container to full-screen (gets size from device properties?).
  2. Styling the container doesn't appear to have any effect.
  3. If I hard-code width and height attributes it will sit inside the container, but I don't want to hard-code these numbers.

If the container is indeed flex:1, I'd expect it to expand to the parent container size rather than the full screen dimensions. Is there a way to achieve this?

Adding and removing pages

Is there a way to add pages, like adding rows to a list view?

When I try to do this naively by rendering a new child view in the Swiper the new views all show up on the last page instead of creating new pages.

Pagination warning (missed keys)

Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of index. It was passed a child from ProfilePictures. See https://fb.me/react-warning-keys for more information.
reactConsoleError @ ExceptionsManager.js:83
warning @ warning.js:42
validateExplicitKey @ ReactElementValidator.js:104
validateChildKeys @ ReactElementValidator.js:203
ReactElementValidator.createElement @ ReactElementValidator.js:338
renderPagination @ index.js:347
render @index.js:494
ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext @ ReactCompositeComponent.js:715ReactCompositeComponentMixin._renderValidatedComponent @ ReactCompositeComponent.js:737ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.mountComponent @ ReactCompositeComponent.js:234ReactPerf.measure.wrapper @ ReactPerf.js:70ReactReconciler.mountComponent @ ReactReconciler.js:37ReactMultiChild.Mixin._mountChildByNameAtIndex @ ReactMultiChild.js:400ReactMultiChild.Mixin._updateChildren @ ReactMultiChild.js:306ReactMultiChild.Mixin.updateChildren @ ReactMultiChild.js:251ReactNativeBaseComponent.Mixin.receiveComponent @ ReactNativeBaseComponent.js:209ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactChildReconciler.updateChildren @ ReactChildReconciler.js:83ReactMultiChild.Mixin._updateChildren @ ReactMultiChild.js:277ReactMultiChild.Mixin.updateChildren @ ReactMultiChild.js:251ReactNativeBaseComponent.Mixin.receiveComponent @ ReactNativeBaseComponent.js:209ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactChildReconciler.updateChildren @ ReactChildReconciler.js:83ReactMultiChild.Mixin._updateChildren @ ReactMultiChild.js:277ReactMultiChild.Mixin.updateChildren @ ReactMultiChild.js:251ReactNativeBaseComponent.Mixin.receiveComponent @ ReactNativeBaseComponent.js:209ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactChildReconciler.updateChildren @ ReactChildReconciler.js:83ReactMultiChild.Mixin._updateChildren @ ReactMultiChild.js:277ReactMultiChild.Mixin.updateChildren @ ReactMultiChild.js:251ReactNativeBaseComponent.Mixin.receiveComponent @ ReactNativeBaseComponent.js:209ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.receiveComponent @ ReactCompositeComponent.js:463ReactReconciler.receiveComponent @ ReactReconciler.js:94ReactCompositeComponentMixin._updateRenderedComponent @ ReactCompositeComponent.js:675ReactCompositeComponentMixin._performComponentUpdate @ ReactCompositeComponent.js:654ReactCompositeComponentMixin.updateComponent @ ReactCompositeComponent.js:564ReactPerf.measure.wrapper @ ReactPerf.js:70ReactCompositeComponentMixin.performUpdateIfNecessary @ ReactCompositeComponent.js:490ReactReconciler.performUpdateIfNecessary @ ReactReconciler.js:112runBatchedUpdates @ ReactUpdates.js:149Mixin.perform @ Transaction.js:140Mixin.perform @ Transaction.js:140assign.perform @ ReactUpdates.js:93flushBatchedUpdates @ ReactUpdates.js:173ReactPerf.measure.wrapper @ ReactPerf.js:70Mixin.closeAll @ Transaction.js:213Mixin.perform @ Transaction.js:154ReactDefaultBatchingStrategy.batchedUpdates @ ReactDefaultBatchingStrategy.js:66enqueueUpdate @ ReactUpdates.js:206enqueueUpdate @ ReactUpdateQueue.js:24ReactUpdateQueue.enqueueSetState @ ReactUpdateQueue.js:233ReactComponent.setState @ ReactComponent.js:72altSetState @ mixinContainer.js:134(anonymous function) @ transmitter.js:21push @ transmitter.js:20StoreModel.emitChange @ AltStore.js:49(anonymous function) @ AltStore.js:97Dispatcher.$Dispatcher_invokeCallback @ Dispatcher.js:220Dispatcher.dispatch @ Dispatcher.js:195(anonymous function) @ index.js:74Alt.batchingFunction @ index.js:56dispatch @ index.js:72dispatch @ index.js:38dispatchIdentity @ AltUtils.js:56action @ index.js:61fire @ StoreMixin.js:79StoreMixin.registerAsync.Object.keys.reduce.publicMethods.(anonymous function).makeActionHandler @ StoreMixin.js:84tryCallOne @ core.js:37(anonymous function) @ core.js:103JSTimers.setImmediate.JSTimersExecution.callbacks.(anonymous function) @ JSTimers.js:79JSTimersExecution.callTimer @ JSTimersExecution.js:68JSTimersExecution.callImmediates @ JSTimersExecution.js:117(anonymous function) @ MessageQueue.js:107guard @ MessageQueue.js:39flushedQueue @ MessageQueue.js:107processBatch @ MessageQueue.js:92messageHandlers.executeJSCall @ debugger-ui:66ws.onmessage @ debugger-ui:93

Only iOS?

Hi,

I would like to use your component in an Android app, is it possible?

Thank you for your hard work.

J

Support for Android

I am planning to use this module for a project and would like to know if this works on Android. All the components used in this repo does not have 'IOS' suffix to it, so I believe it should be fine. :)

Memory Leak with 100-page slider (and images)

I have a slider that swipes through about 100 1/2-page images. It looks great, and works great on the simuator. However, when I run it live it runs for a few seconds, and then crashes with the below error in XCode:

Terminated due to memory error
And in the Output on XCode: Received memory warning.

On my end, I'm building out the jsx dynamically (I loop over my list of items and make jsx for each using items.map).

I'm not sure why it's causing it to crash. Has anyone else seen this?

Performance optimization concerning huge pages

Hello,

first of all: thanks a lot for this nice swiper! I'm currently using it for about 20 pages, each of the pages being quite big. Is there any way to optimize the rendering (e.g. render only some pages next to the currently active page), as the initial loading is taking about 3 seconds in my case at the moment.

Regards
Philipp

Initial index not working?

Hi
I cannot set the initial index. It always shows the first page. What is wrong?

Thank you
Bernd

In this example I expect the page at index 3 to be the visible at startup, but it is not :(

    render() {
        return (
            <Swiper showsButtons={false} index={3}>
                {this.props.route.approvalIds.map(function (approvalId, pageIndex) {
                    return (
                        <View style={{flex: 1}} key={pageIndex}>
                            <Approval approvalId={approvalId} pageIndex={pageIndex} pageCount={this.props.route.approvalIds.length} />
                        </View>
                    );
                }.bind(this))}
            </Swiper>
        );
    }

Example Error

I just tried your example and I get this error in the console.

"Warning: Failed propType: Invariant Violation: index: prop type renderPagination is invalid; it must be a function, usually from React.PropTypes. "

I'm following your "Basic usage" in the readme.md so I'm not passing anything to renderPagination. I wonder if it's in your lib code?

Dynamic Items

I'm loading remote data and then setup my views, but when I generate them dynamically it stacks them on a single screen. It looks like its grabbing the children in getInitialState() and they aren't available yet. When render() runs the children are there, but the total is set to 1.

Allow a prop to update (and animate to) a new active index

Hello,

I'd like to allow the parent component of the slider to update the current index of the pager and have it animate to that page. Right now it doesn't seem to do that.

I've tried to tweak the code a bit in order to do this using the componentWillReceiveProps lifecycle method, but I can't seem to get it to work.

Anyway, if you could add this, that would be great.

Thanks.

Callbacks for each slide

There should be away to execute code based on if you are currently on a certain slider. This could be a prop called onView or something that receives a callback function.

Use case:
There are multiple slides in the swiper. On the last slide, you can auto-focus on a text field at the same time onMomentumScrollEnd is called

WebView inside swiper reloads

I'm using a Swiper to wrap a couple of WebViews.
But each time I swipe, the WebView reloads (and scrolls to the top).

scrollTo method

Hi,

I looked into your code to use it with tabs, the scrollTo(index) method was great but is bugged. You should get rid of the this.state.index which has nothing to do here. This took me so much time to find the problem so I share it !

scrollTo() breaks after attempting to swipe to cell before first

Title says it all really. If I have a swiper that has 4 slides and on the first slide I have button that call scrollTo(index) they all work but it I then swipe back to the start and try to swipe one extra slide before the start then scrollTo(index) stops working. Manually swiping to the second slide and back again corrects the issue.

WebView overrides horizontal scrolling

Is there a way to navigate to the next page when the user is still scrolling left or right but there's nothing more to scroll inside a webview ?

Thanks

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.