javascripthtmldrag-and-dropdragulang2-dragula

dragula - how to disable dragging in its parent container


I like how dragula works, but one thing I couldn't find solution to, is how I can disable the function of drag and drop in the same container the element is currently in. I only want to drag elements into other containers not sort them manually.


Solution

  • You let it return false from the accept-option (a function)

    This is from the ionic setup, but it's same-same:

    Inside the constructor:

         dragulaService.setOptions('my-bag', {
               accepts: (el, target, source, sibling) => {
                if (!target || !source || (target == source))
                  return false;
               }
         });