dragend, dragenter, and dragleave firing off immediately when I drag

后端 未结 6 911
梦谈多话
梦谈多话 2020-12-29 05:02

I\'m trying to make a list of elements which can be repositioned by dragging and dropping. The first element, Box 1, works just fine 100% of the time. Sometimes the second b

6条回答
  •  旧时难觅i
    2020-12-29 05:32

    You need to prevent the "event" from bubbling up so it doesn't fire up other events. See https://developer.mozilla.org/en-US/docs/DOM/event.stopPropagation

    For startDrag, toggleDropStyles, removeDropSpaces functions, you'd write something like this:

    function startDrag(ev) {
       ev.stopPropagation();
       ... your code here ...
    }
    

提交回复
热议问题