react-draggable
react-draggable copied to clipboard
How to position based on container
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
Use the second argument to get the coordinates
const onDragStop = (event, ui) => {
event.preventDefault()
const { x, y } = ui
}