JSFiddle - React, Tailwind, and code Playground
by InviS
HTML
<div id='draggable'>
<div class='coordinates'>0, 0</div>
</div>
CSS
#draggable{
width: 100px;
height: 100px;
background-color: grey;
overflow: hidden;
}
.coordinates{
padding: 3px 0;
background-color: #eee;
margin-top: 35px;
text-align: center;
}
JavaScript
$('#draggable').draggable({
drag: function(){
offset = $(this).offset();
$(this).find('.coordinates').html(offset.left+', '+offset.top);
// ...callbacks...
}
});