簡體   English   中英

帶有InteractionManager的React-Native .scrollTo無法正常工作

[英]React-Native .scrollTo with InteractionManager not working

我正在嘗試在x:(device.width * 2)處獲取應用的初始位置,因為該應用包含3個主要視圖,但即使有動畫延遲,它似乎也沒有移動,它從左側開始視圖。

componentDidMount() {
      const offset = window.width * this.props.initialIndex;
        InteractionManager.runAfterInteractions(() => {
        this._scrollView.scrollTo({x:offset, animated: false});
      })
}

我也嘗試過使用Interaction Manager,但我不知道為什么它不起作用。 設置超時對我有用。

setTimeout(() => {
    this.scrollView.scrollTo(cordenates, animated);
}, 0);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM