how to disable dragend animation in html5

后端 未结 1 1141
庸人自扰
庸人自扰 2021-01-12 10:36

html is

and I can drag this div,but when I drop the element, there is a animat

相关标签:
1条回答
  • 2021-01-12 10:44

    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() })
    

    Example in MDN docs shows the same thing: https://developer.mozilla.org/en-US/docs/Web/Events/drop#Example

    An old blog post describing the quirks of HTML5 Drag and Drop API: https://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html

    0 讨论(0)
提交回复
热议问题