From 7752e1bbfb103074190102f3fe01528c98acd3fa Mon Sep 17 00:00:00 2001 From: Li Zheng Date: Fri, 25 Aug 2017 14:55:08 +0800 Subject: [PATCH 1/3] Fix `Uncaught TypeError: _this.refs.scrollView.scrollTo is not a function` when using https://github.com/flyskywhy/react-web --- src/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 743cccdd..88b98392 100644 --- a/src/index.js +++ b/src/index.js @@ -570,10 +570,14 @@ export default class extends Component { ) } + refScrollView = view => { + this.scrollView = view; + } + renderScrollView = pages => { if (Platform.OS === 'ios') { return ( - Date: Mon, 4 Sep 2017 14:33:25 +0800 Subject: [PATCH 2/3] typo --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 88b98392..cd46e7a2 100644 --- a/src/index.js +++ b/src/index.js @@ -263,7 +263,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) } @@ -420,9 +420,9 @@ export default class extends Component { if (state.dir === 'y') y = diff * state.height if (Platform.OS === 'android') { - this.refs.scrollView && this.refs.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) + 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 From adee8595d3afa9ed00aa7b794645a6be33e7bd74 Mon Sep 17 00:00:00 2001 From: Li Zheng Date: Mon, 4 Sep 2017 15:46:54 +0800 Subject: [PATCH 3/3] Actually fix `Uncaught TypeError: _this.refs.scrollView.scrollTo is not a function` when using https://github.com/flyskywhy/react-web --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index cd46e7a2..2595be61 100644 --- a/src/index.js +++ b/src/index.js @@ -419,7 +419,7 @@ 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') { + if (Platform.OS !== 'ios') { this.scrollView && this.scrollView[animated ? 'setPage' : 'setPageWithoutAnimation'](diff) } else { this.scrollView && this.scrollView.scrollTo({ x, y, animated }) @@ -432,7 +432,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: {