bmcmahen / react-grid-dnd

drag and drop, grid edition. built with react

Home Page:https://codesandbox.io/embed/gracious-wozniak-kj9w8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help to make onChange function that sends item to the end everytime

YahiyaHussain opened this issue · comments

function onChange(sourceId, sourceIndex, targetIndex, targetId) {
        if (targetId) {
          const result = move(
            tileState[sourceId],
            tileState[targetId],
            sourceIndex,
            targetIndex
          );
          return setTileState({
            ...tileState,
            [sourceId]: result[0],
            [targetId]: result[1]
          });
        }
    
        const result = swap(tileState[sourceId], sourceIndex, targetIndex);
        return setTileState({
          ...tileState,
          [sourceId]: result
        });
      }

Here is my current onChange function and it works, but I want it to always put the item at the end when dragged rather than swapping with an element it collides with while dragged when released like it currently does. How would I write that?