React Native:在项目摆动回到其原始位置无偏移后,拖动停止工作

问题描述

我的0.62.2应用程序中有一个简单的拖动动画。拖动是通过react-native-gesture-handler 1.6.1react-native-reanimated 1.10.1实现的。拖动的项目是网格中的图像。连续有2个网格或3个网格可显示图像。这是代码

        const dragX = new Value(0);
        const dragY = new Value(0);
        const state = new Value(-1);
        const handleGesture = event([
            {
              nativeEvent: {
                translationX: dragX,translationY: dragY,state,},]);
        let aniStyle = {
            transform:[
                { translateY : dragY },{ translateX : dragX }
            ]
        };
        return (
          <PanGestureHandler 
               onGestureEvent={handleGesture} 
               onHandlerStateChange={handleGesture}>
             //image item goes here
          </PanGestureHandler>
        )

没有定义偏移量,因此在与光标一起移动之前,图像将通过第二次拖动或向后拖动回到原始位置。第一次拖动后,我注意到单击图像时,图像会摆动回到其原始位置,并停止响应再次拖动。或者,如果单击该图像,则拖动将完全不起作用。有办法解决这个问题吗?

代码在Android模拟器中执行。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)