【发布时间】:2019-01-15 08:36:52
【问题描述】:
我有一个动画视图,我想在 onScroll 属性中执行多个事件。现在onScroll 是这样的:
onScroll={
Animated.event(
[{ nativeEvent: { contentOffset: { y: this.scroll } } }],
{ useNativeDriver: true },
)
我想做一些比Animeted.event() 更多的事情。所以我把它放在这样的函数中:
animatedEv(){
Animated.event(
[{ nativeEvent: { contentOffset: { y: this.scroll } } }],
{ useNativeDriver: true },
)
//----and maybe some thing more here
}
我把你在上面看到的onScroll称为:
onScroll={()=>
this.animatedEv
}
但尽管调用了成功函数,但动画在这些新样式中无法正常工作....即使我试过这个:
onScroll={
()=>{this.animatedEv() }
}
在这两种风格中都没有错误,但动画无法正常工作):
编辑: 这是我的滚动,它是我组件顶部的一个变量:
scroll = new Animated.Value(0);
【问题讨论】:
-
以上问题有解决办法吗?
标签: javascript android reactjs typescript react-native