metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.13k stars 315 forks source link

packery draggabilly: prevent from dropping over a .stamp.non-drop item. #561

Open jayenne opened 2 years ago

jayenne commented 2 years ago

I have a case where I'd like to force an element to always be the first* item where it can not move or be dropped over.

I have tried with stamp but can still drag'n'drop over the stamped item. ideally, it may be nice if 'stamp' could have a non-drop option which prevents any item being dragged fro mdropping over it (on drop, it would revert back to the position from where it was picked up). Whilst draggon over an "non-movable stamped item" the item being dragged would have a class classed that may be styled to visually indicate to the user that this item is within a non-drop zone.

thanks in advance,

rawthriver commented 2 years ago

+1 The workaround is to perform layout in dragItemPositioned event if order was not changed, for example:

container.on('dragItemPositioned', function() {
  if (!orderChanged()) {
    setTimeout(function() {
      container.packery('layout');
    }, 16);
    return;
  }
  saveOrder();
});
rawthriver commented 2 years ago

Using this in addition solves the problem, but I would like some standard solution https://github.com/desandro/draggabilly/issues/177