【发布时间】:2019-04-07 19:54:43
【问题描述】:
在 react-native 中,我使用的是找到 here 的 Swiper 模块:
<Swiper
bounces={true}
loop={false}
showsPagination={false}
onScroll={this.handleScroll}
scrollEventThrottle={1}
>...
然后在渲染方法之外,我这样定义handleScroll:
handleScroll = Animated.event(
[{ nativeEvent: { contentOffset: { x: this.state.left } } }],
{
listener: event => {
console.log(this.state.left);
}
});
在 Swiper 上执行滚动并查看输出时,没有任何变化。
我知道将 Animated.event 直接放入 onScroll 中,它的工作原理是这样的,但我很好奇为什么它不起作用
【问题讨论】:
标签: react-native scroll react-animated