muuri
muuri copied to clipboard
Refuse to receive item
How do I let the grid to not receive the item and send it back? I tried the following code but it is not working.
grid.on('receive',function(data){
grid.send(data.item,data.fromGrid,data.fromIndex)
})
If I wait till "dragReleaseEnd", I can successfully send it to another grid but I lose the information where the item is from and the original index.
grid.on('dragReleaseEnd',function(item){
grid.send(item,anotherGrid,-1)
})
```'
you can use getGrid() on the 'dragStart' event and store the initiating grid for future use in the 'dragReleaseEnd' event
let currentDragGrid;
muuriGrid.on('dragStart', function (item, event) {
currentDragGrid = item.getGrid()
});.
muuriGrid.on('dragReleaseEnd', function (item) {
if (currentDragGrid) {
//do your own code
currentDragGrid = null;
}
}
});