7

http://www.html5rocks.com/en/tutorials/dnd/basics/

In the example here (scroll to the bottom and try the last example), when you drag out the element and don't drop it anywhere, it is positioned back to its default place and there is an animation for positioning to its default place (Chrome/Safari). I would like to disable that animation.

Is there some sort of special property for webkit, that will allow me to do this?

puppeteer701
  • 1,225
  • 3
  • 17
  • 33

1 Answers1

1

Found answer here and it works in my case https://stackoverflow.com/a/51697038/1770586

In order to prevent the animation, you need the drop event to fire. For the drop event to fire, you need to call preventDefault() in the handler for dragover.

document.addEventListener('dragover', function(e) { e.preventDefault() })

jaromudr
  • 151
  • 8
  • 1
    Just want to add that this isn't fool proof: pressing the escape key for example will cancel the drag without firing your drop handler. – Alex Guerra Nov 24 '20 at 20:37