diff --git a/src/index.js b/src/index.js index 97b3219f..3036d4e1 100644 --- a/src/index.js +++ b/src/index.js @@ -269,7 +269,7 @@ export default class extends Component { loopJump = () => { if (!this.state.loopJump) return const i = this.state.index + (this.props.loop ? 1 : 0) - const scrollView = this.refs.scrollView + const scrollView = this.scrollView this.loopJumpTimer = setTimeout(() => scrollView.setPageWithoutAnimation && scrollView.setPageWithoutAnimation(i), 50) } @@ -425,10 +425,10 @@ export default class extends Component { if (state.dir === 'x') x = diff * state.width if (state.dir === 'y') y = diff * state.height - if (Platform.OS === 'android') { - this.refs.scrollView && this.refs.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) + if (Platform.OS !== 'ios') { + this.scrollView && this.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) } else { - this.refs.scrollView && this.refs.scrollView.scrollTo({ x, y, animated }) + this.scrollView && this.scrollView.scrollTo({ x, y, animated }) } // update scroll state @@ -438,7 +438,7 @@ export default class extends Component { }) // trigger onScrollEnd manually in android - if (!animated || Platform.OS === 'android') { + if (!animated || Platform.OS !== 'ios') { setImmediate(() => { this.onScrollEnd({ nativeEvent: { @@ -579,10 +579,14 @@ export default class extends Component { ) } + refScrollView = view => { + this.scrollView = view; + } + renderScrollView = pages => { if (Platform.OS === 'ios') { return ( -