react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

How to position based on container

Open IsmaFunes opened this issue 4 years ago • 1 comments
trafficstars

I'm trying to center an element in the middle of its container and only allow to drag it inside it. Is there a way to do that without having to calculate it myself?

Also, how to grab the x and y values on the onStop handler based on the container size instead of window size?

Thanks

IsmaFunes avatar May 01 '21 20:05 IsmaFunes

Use the second argument to get the coordinates

 const onDragStop = (event, ui) => {
    event.preventDefault()
    const { x, y } = ui
}

wmonecke avatar Jul 15 '21 12:07 wmonecke