【问题标题】:Fire an event on scrollend of the screen在屏幕的滚动端触发事件
【发布时间】:2018-06-22 06:14:32
【问题描述】:

我想在应用屏幕的滚动端触发一个事件。我正在使用本机基卡和列表视图。我在 onscrollend 事件中尝试过。但似乎没有任何效果。有没有更好的方法来检测屏幕的滚动结束?

【问题讨论】:

标签: react-native native-base


【解决方案1】:

ListView 组件中使用 onEndReached 函数,它在所有行都已呈现并且列表已滚动到 onEndReachedThreshold 内时调用底部。提供了本机滚动事件。

onEndReachedThreshold 调用 onEndReached 的阈值(虚拟,非物理)。

如我所见:如果您执行 onEndReachedThreshold ={100},如果您从底部滚动到 100 像素,它会调用 onEndReached

示例:

          <ListView
            {..........} 
            onEndReachedThreshold={100}
            onEndReached={() => {
                            console.log("fired"); // keeps firing
                          }}

           />

【讨论】:

    【解决方案2】:

    使用组件的 onEndReached 和 onEndReachedTreshold 属性。 Flatlist 是比 ListView 进行无限滚动的更好选择。

    【讨论】:

      猜你喜欢
      • 2015-05-28
      • 2014-08-28
      • 2020-04-09
      • 1970-01-01
      • 2017-08-09
      • 2011-04-25
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      相关资源
      最近更新 更多