react-native-navigation是否有backToTop?

时间:2018-07-02 22:51:20

标签: react-native-navigation wix-react-native-navigation

当用户已经在屏幕上时点击底部导航栏上的选项卡时,我想将用户带回屏幕顶部。有谁知道我可以使用react-native-navigation做到这一点吗?

1 个答案:

答案 0 :(得分:1)

弄清楚了。

将此添加到要向上滚动的页面。

echo 1 > /proc/sys/net/ipv4/ip_forward

如果您想了解有关设置导航器事件的更多信息,则可以签出:

https://wix.github.io/react-native-navigation/#/screen-api?id=listening-to-tab-selected-events

然后添加此功能:

 constructor(props) {
    super(props);
    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
  }

并将其添加到您的ScrollView:

onNavigatorEvent(event) {
    if (event.id === 'bottomTabSelected') {
      console.log('Tab selected!');
    }
    if (event.id === 'bottomTabReselected') {
      console.log('Tab reselected!');
      this.refs._scrollView.scrollTo({x: 0, y: 0, animated: true});
    }
  }

感谢:

https://github.com/wix/react-native-navigation/issues/1719