首页 > 解决方案 > Interrupt a drag&drop in progress

问题描述

I have an Angular7 application where I'm using native HTML Drag&Drop. When the dragged item enter in a specific area (catch with dragenter event), I want to force the interruption of the current drag operation.

But I could not find a way to do that in native JavaScript or Angular.

I put a dragenter event on the div of this specific area and tried many solutions when it trigger :

preventDefault() or stopPropagation() don't work and I also tried to simulate a mouseup and a keyboard (escape press) events with a dispatchEvent : document.getElementById('interruptArea').dispatchEvent(AnEvent)

That's all I tried, didn't find anything else. Do you know if there are a way to do this ?

Thanks for your help !

标签: javascriptangulardrag-and-drop

解决方案


推荐阅读