Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在ScrollView onscroll属性中调用函数_Javascript_Android_Reactjs_Typescript_React Native - Fatal编程技术网

Javascript 在ScrollView onscroll属性中调用函数

Javascript 在ScrollView onscroll属性中调用函数,javascript,android,reactjs,typescript,react-native,Javascript,Android,Reactjs,Typescript,React Native,我有一个动画视图,我想在onScroll属性中执行多个事件。现在的重点是: 我想做一些事情,而不仅仅是批评这件事。所以我把它放在这样一个函数中: animatedEv(){ Animated.event( [{ nativeEvent: { contentOffset: { y: this.scroll } } }], { useNativeDriver: true }, ) //----and maybe some thing m

我有一个动画视图,我想在onScroll属性中执行多个事件。现在的重点是:

我想做一些事情,而不仅仅是批评这件事。所以我把它放在这样一个函数中:

animatedEv(){
    Animated.event(
        [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
        { useNativeDriver: true },
    )
        //----and maybe some thing more here 
} 
我把你在onScroll上面看到的称为:

但是,尽管调用了success函数,动画在这些新样式中仍然无法正常工作……即使我尝试了以下方法:

onScroll={
            ()=>{this.animatedEv() } 
  } 
在这两种样式中都没有错误,但动画无法正常工作:

编辑: 这是我的卷轴,它是我的组件顶部的一个变量:

 scroll = new Animated.Value(0);
当你使用

onScroll={
    Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
    { useNativeDriver: true },
)}
它类似于

onScroll={(scrollEvent) => {
    Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
    { useNativeDriver: true },
))(scrollEvent)
}}
因此,如果您想从中获取代码,请尝试

animatedEv = (event) => {
    Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
    { useNativeDriver: true },
    ))(event)
    //other stuff
};
...
onScroll={this.animatedEv}

编辑:第一个答案错误

以上问题有解决方案吗?
onScroll={(scrollEvent) => {
    Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
    { useNativeDriver: true },
))(scrollEvent)
}}
animatedEv = (event) => {
    Animated.event(
    [{ nativeEvent: { contentOffset: { y: this.scroll } } }],
    { useNativeDriver: true },
    ))(event)
    //other stuff
};
...
onScroll={this.animatedEv}