DefaultPosition uses a different Y than onDrag?
Hi,
I was trying to save my draggable's position by storing the coordinates as such:
onDrag = (e, ui) => {
this.props.state.x = e.clientX;
this.props.state.y = e.clientY;
}
And to use those values when loading the saved item:
<Draggable
handle={'.dragDiv'}
bounds={'parent'}
defaultPosition={{ x: this.props.state.x, y: this.props.state.y }}
onDrag={this.onDrag}
onStop={this.onDragStop}>
When I dragged the draggable to the top left, the state was {x:0, y:0} as expected. However, when loading the component again, the component appeared in the middle left of the page instead of top left.
Is this intended behavior? Or is there maybe something wrong with my parent element's settings?
EDIT: I was able to solve the issue by using absolute positioning and left-top-values, but I think it would be much cleaner to use defaultPosition.
I am having issues with defaultPosition as well - it is simply ignored in most cases, so definitely a bug.
Returning to this after a long time.
The correct solution is to use ui.x and ui.y instead of the data contained in the event itself.
Getting the same issue, ui.x and ui.y is doesn't works properly with default position.