In my react project i would like to get current position of this div that i can drag around on screen. I mean current XY coordinates
I think you want to listen to is the Drag Event - take a look at the Mozilla Documentation for good examples
Remember in React the events will be referred to in camel case - onDragStart
, onDragEnd
, etc.
// A sample drag handler where you are getting the elements coordinates
function onDragStartHandler (ev) {
var rect = ev.target.getBoundingClientRect();
console.log(rect.top, rect.right, rect.bottom, rect.left);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.