JSFiddle - React, Tailwind, and code Playground
HTML
<div style="left:20px;top:20px;">original</div>
<div id="sally" class="clone" hidden>sally</div>
CSS
body {
background: black;
}
div {
-webkit-user-drag: element;
background: red;
height: 100px;
position: fixed;
width: 100px;
}
.clone {
background: white;
pointer-events: none;
}
JavaScript
var orig = document.querySelector('div');
var sally = document.getElementById('sally');
orig.ondragstart = function() {
sally.hidden = false;
};
orig.ondrag = function(e) {
sally.style.left = e.clientX + 'px';
sally.style.top = e.clientY + 'px';
};
orig.ondragend = function() {
sally.hidden = true;
};