I use the html5 attribute 'draggable' to drag two elements in the container and the svg line to connect the two. After connecting, dragging the first Div, you need to redraw the svg connector string (I do this when dragging and dropping by calling the handleDragOver function). But if you drag the first div faster, the drop event does not fire, and the div keeps it in its original place while the line is being drawn.
function handleDragOver(e) { if (e.preventDefault) { e.preventDefault(); } //Some code doing DOM computation and manipulation } return false; //e.dataTransfer.dropEffect = 'move'; }
How can I guarantee that the drop event fires every time.
Note:
- I can not use any framework, just javascript
- I cannot redraw the line while dragging and dropping.
- The drag and drop function works fine when I don't do any calculations / redraws in 'handleDragOver'
Here is the code: http://jsfiddle.net/bhuwanbhasker/3yx9ds4m/1/
source share