Sortable icon indicating copy to clipboard operation
Sortable copied to clipboard

OnSpill plugin is not working with multi drag. Is there a way to achieve revertOnSpill with multi drag?

Open yagnikvarma opened this issue 6 years ago • 1 comments

yagnikvarma avatar Sep 12 '19 01:09 yagnikvarma

I'm facing the same issue, 3 years later. Is there any progress with this issue ? Thanks.

UPDATE: meanwhile, the only work around I was able to find for this (by all means, if anyone has a better way, please share) is by setting a global boolean value in my page. I.e.

window.spilled = false;

var sortable = Sortable.create( el, {
   
   //...

   revertOnSpill: true,
   onSpill: function(evt) {
      if(evt.items.length > 1){
         window.spilled = true; // flag we've spilled: onEnd will take care of moving items back to source group
      }
   },


   onEnd: function (evt) {

      // little hack: the revertOnSpill does not work with multiDrag;
      // move back items to source list by checking a flag set in onSpill
      if(window.spilled) {

         // move back items to bottom of source: @TODO would be nice to reinsert them at their original position
         evt.items.forEach( function(item){
            $('#' + item.id).detach().appendTo('#sourceList');
         });

         // reset spilled state
         window.spilled = false;
      }
      else {      
         // do what ever you need to finalize the move...
      }
   },
});

If this helps anyone meanwhile ;)

ravenlost avatar Aug 31 '22 10:08 ravenlost