muuri icon indicating copy to clipboard operation
muuri copied to clipboard

Refuse to receive item

Open peterming3 opened this issue 4 years ago • 1 comments

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)
})
```'

peterming3 avatar Jul 19 '20 22:07 peterming3

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;
            }
        }
    });

mehdiqanavatian avatar Nov 22 '20 06:11 mehdiqanavatian