I have a website that drags an element over to a drop zone. The problem is when you drop an element, a lot stuff in the back end has to update. Due to this, the cursor position won't update until to move the cursor.
This JSFiddle sort of reproduces the problem
When you drag the line over to the bottom div and don't move the cursor, it still thinks the cursor location is in the original spot before it dragging, so the hover still displays red. Once you move the cursor it updates.
This is the code:
HTML:
<div id="div1">
<li draggable="true" ondragstart="drag(event)">Drag this line</li>
</div>
<br><br />
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
CSS:
#div1, #div2 {
width: 350px;
height: 70px;
padding: 10px;
border: 1px solid #aaaaaa;
}
li:hover {
background-color: red;
}
JS:
function allowDrop(ev) {
ev.dataTransfer.dropEffect = 'link'
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("Text", ev.target.id);
}
function drop(ev) {
var data = ev.dataTransfer.getData("Text");
var lag = 0 //This just simulates a lot of things going on, not really real code
for (i = 0; i < 500; i++) {
lag += i
lag /= 2
console.log(lag)
}
ev.target.innerHTML = "If you don't move your mouse, it'll still be hovering over the line, if you move the mouse it updates"
ev.preventDefault();
}
EDIT: I tried
html.busy, html.busy * {
cursor: wait !important;
}
in the CSS
This helped the issue, but some rare moments it doesn't work and it also doesn't work when you have a window.alert() when you drop it,
shown here