Help to make onChange function that sends item to the end everytime
YahiyaHussain opened this issue · comments
Yahiya Hussain commented
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?