アニメーションScrollView
を作成するAnimated.createAnimatedComponent(ScrollView)
を使用している場合、それはscrollTo
を使用することはできません長い上で定義されていません。 this.list.scrollTo({x: 0, y: 0})
を呼び出すscrollToは、アニメーションScrollView
const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
<AnimatedScrollView ref={(ref) => this.list = ref}>
<View style={{height: 1000}} />
</AnimatedScrollView>
は、次のエラーを与える:
_this.list.scrollTo is not a function
それは通常のScrollViewに正常に動作します。これを解決する方法はありますか? this.list.scrollTo({x: 0, y: 0})
が動作するはず呼び出し、その後
ref={(ref) => this.list = ref._component}
:
getNode()でうまく見つかりました。私は 'ref = {c => this.myRef = c.getNode()}'に書き直すことができるので、常に 'getNode()'を呼び出す必要はありません。 –
私は実際にそれを試みましたが、未定義のエラーが発生しました - その時点でデバッグする時間がありませんでしたが、もし答えが得られれば自由に編集できます:-) – jhm
アニメーションスクロールビューを使って、この情報を把握していただきありがとうございます。 1つの注意点は 'ref = {ref => this.scrollView = ref.getNode()}'は私のためには動作しませんが、 'this.scrollView.getNode()。scrollTo()'はうまくいきます。 – Nathan