From 57b65e9e55d244644ee42557e9548458ad260cdb Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Tue, 22 Dec 2015 21:35:58 +0800 Subject: [PATCH 1/2] fix dots --- src/index.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/index.js b/src/index.js index 499f46d..fd48d59 100644 --- a/src/index.js +++ b/src/index.js @@ -333,24 +333,32 @@ export default React.createClass({ if(this.state.total <= 1) return null let dots = [] - let CustomDot = this.props.dot - let CustomActiveDot = this.props.activeDot - for(let i = 0; i < this.state.total; i++) { - dots.push(i === this.state.index - ? ( || ) - : ( || ; + let Dot = this.props.dot || ) + marginLeft: 3, + marginRight: 3, + marginTop: 3, + marginBottom: 3, + }} />; + for(let i = 0; i < this.state.total; i++) { + dots.push(i === this.state.index + ? + React.cloneElement(ActiveDot, {key: i}) + : + React.cloneElement(Dot, {key: i}) ) } From 58b9dddd5f141c5f85a22fbf878f15c73dc66b80 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Tue, 22 Dec 2015 22:20:51 +0800 Subject: [PATCH 2/2] add simple support for android add simple support for android. No props handled yet. --- src/index.js | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index fd48d59..fa2a798 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,7 @@ import React, { ScrollView, TouchableOpacity, Dimensions, + ViewPagerAndroid } from 'react-native' // Using bare setTimeout, setInterval, setImmediate @@ -421,7 +422,25 @@ export default React.createClass({ ) }, - + renderScrollView(pages) { + if (Platform.OS === 'ios') + return ( + + {pages} + + ); + return ( + + {pages} + + ); + }, /** * Inject state to ScrollResponder * @param {object} props origin props @@ -489,14 +508,7 @@ export default React.createClass({ width: state.width, height: state.height }]}> - - {pages} - + {this.renderScrollView(pages)} {props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total, this) : this.renderPagination())}