Drag and Drop between two draggable Flatlist-React Native

后端 未结 2 1302
长发绾君心
长发绾君心 2021-02-10 15:59

I\'m struggling to create a requirement for my React-Native application where I am having a blank dropbox(on dropping a flatlist item it should convert into a draggable flatlist

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-10 17:06

    More performant way using declarative api from react-native-reanimated

     }
     />
    
    
    const GestureItem = ({item})=> {
      const safex = new A.Value(0)
      const safeY = new A.Value(0)
      const draX = new Value(0)
      const dragY = new Value(0)
      const panState = new Value(State.UNDETERMINED)
      const onGestureEvent = A.event([
          {
            nativeEvent: {
              translationX: dragX,
              translationY: dragY,
              state: panState,
            },
          },
        ]);
    
       const transX = cond(
          eq(panState, State.ACTIVE),
          dragX,
          set(safeX, add(safeX, dragX))
        );
    
       const transY = cond(
          eq(panState, State.ACTIVE),
          dragY,
          set(safeY, add(safeY, dragY))
        );
      return (
        
    
          
         
        
    
    
      )
    }
    

    For swaping list items and their indexes use Code component

提交回复
热议问题