Skip to content

Commit 8fbcd47

Browse files
committed
fix: use last on drag stop position if it's not avalible
If position is not avalible on drag stop, use last position. This fixes tests for react-grid-layout#621
1 parent 7566939 commit 8fbcd47

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/DraggableCore.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ export default class DraggableCore extends React.Component<DraggableCoreProps, D
385385
if (position == null) return;
386386
let {x, y} = position;
387387

388+
// if we couldn't get position from event use lastX and lastY
389+
if (isNaN(x)) x = this.state.lastX;
390+
if (isNaN(y)) y = this.state.lastY;
391+
388392
// Snap to grid if prop has been provided
389393
if (Array.isArray(this.props.grid)) {
390394
let deltaX = x - this.state.lastX, deltaY = y - this.state.lastY;

0 commit comments

Comments
 (0)