JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://raw.github.com/emehrkay/DragPercent/master/Source/Drag.Percent.js"></script>
<div id="c">
<div id="i"></div>
</div>
CSS
#c{
width: 200px;
height: 200px;
position: relative;
border: 1px solid;
overflow: hidden;
top: 150px;
left: 75px;
}
#i{
position: absolute;
top: 0%;
left: 0%;
width: 50%;
height: 50%;
background: red;
}
JavaScript
var i = $('i'),
c = $('c'),
drag = new Drag.Percent(i, c, {
onDrag: function(){
i.set('text', 'x: '+ i.getStyle('left') +' y: '+ i.getStyle('top'));
}
});