scrollTo is undefined on animated ScrollView

前端 未结 5 1859
不知归路
不知归路 2021-02-02 08:03

When using Animated.createAnimatedComponent(ScrollView) to create an animated ScrollView it\'s not longer possible to use scrollTo.

<
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 08:45

    If RN >= 0.59 (maybe earlier) and the following Ref setup:

    const ScrollViewX = Animated.createAnimatedComponent(ScrollView);

      _scrollView = React.createRef();
    
    
    

    You can manually scroll an Animated component this way :

    this._scrollView.current._component.scrollTo({x: number, y: number, animated: true|false})

    (ScrollToOffset is deprecated and probably removed in 0.6)

提交回复
热议问题