I am making a simple drag and drop functionality using react draggable but at the same time while dragging I want to get the top,left,right,bottom axis. I am using getBoundingClientRect But this function emitting same value while element is dragged.
handleOnDrag(e,id){
const {left,right,top,bottom} = document.getElementById('drag').getBoundingClientRect()
let payload = {
left:left,
right:right,
top:top,
bottom:bottom
}
console.log(payload) //same while dragging
}
return (
// currentImageUrl
<div id="drag" onDrag={(e,data) => this.handleOnDrag(e,data,id)} key={data.get('id')} style={{position:'absolute',transition:'0.2s',zIndex:'1px',display:'block'}} className="img">
<Draggable key={i} >
<img style={{height:data.get('height')/heightWidth,width:data.get('width')/heightWidth}} src={currentImageUrl} alt=""/>
</Draggable>
</div>
)
Please help. Thanks.