Auto play issue when only a child view | fixes #19

This commit is contained in:
leecade
2015-12-23 02:57:43 +08:00
parent 3b355c918f
commit 4f86efb1db
3 changed files with 7 additions and 6 deletions

4
dist/index.js vendored
View File

@@ -209,7 +209,7 @@ module.exports = _reactNative2.default.createClass({
autoplay: function autoplay() {
var _this = this;
if (!this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) return;
if (!Array.isArray(this.props.children) || !this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) return;
clearTimeout(this.autoplayTimer);
@@ -302,7 +302,7 @@ module.exports = _reactNative2.default.createClass({
* @param {number} index offset index
*/
scrollTo: function scrollTo(index) {
if (this.state.isScrolling) return;
if (this.state.isScrolling || this.state.total < 2) return;
var state = this.state;
var diff = (this.props.loop ? 1 : 0) + index + this.state.index;
var x = 0;

View File

@@ -209,7 +209,7 @@ module.exports = _reactNative2.default.createClass({
autoplay: function autoplay() {
var _this = this;
if (!this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) return;
if (!Array.isArray(this.props.children) || !this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) return;
clearTimeout(this.autoplayTimer);
@@ -302,7 +302,7 @@ module.exports = _reactNative2.default.createClass({
* @param {number} index offset index
*/
scrollTo: function scrollTo(index) {
if (this.state.isScrolling) return;
if (this.state.isScrolling || this.state.total < 2) return;
var state = this.state;
var diff = (this.props.loop ? 1 : 0) + index + this.state.index;
var x = 0;

View File

@@ -206,7 +206,8 @@ module.exports = React.createClass({
* Automatic rolling
*/
autoplay() {
if(!this.props.autoplay
if(!Array.isArray(this.props.children)
|| !this.props.autoplay
|| this.state.isScrolling
|| this.state.autoplayEnd) return
@@ -301,7 +302,7 @@ module.exports = React.createClass({
* @param {number} index offset index
*/
scrollTo(index) {
if(this.state.isScrolling) return
if (this.state.isScrolling || this.state.total < 2) return
let state = this.state
let diff = (this.props.loop ? 1 : 0) + index + this.state.index
let x = 0