From c7d4f2792dac947b99346c201e293af8e5daac01 Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Fri, 28 Aug 2020 20:24:22 -0700 Subject: [PATCH 1/2] Update index.tsx fix the typo on onDrag method, and make it match with the return result of onDragStop --- src/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 6dd9d14e..c8f514d5 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -360,8 +360,11 @@ export class Rnd extends React.PureComponent { onDrag(e: RndDragEvent, data: DraggableData) { if (this.props.onDrag) { - const offset = this.offsetFromParent; - return this.props.onDrag(e, { ...data, x: data.x - offset.left, y: data.y - offset.top }); + // const offset = this.offsetFromParent; + // return this.props.onDrag(e, { ...data, x: data.x - offset.left, y: data.y - offset.top }); + const { left, top } = this.offsetFromParent; + return this.props.onDragStop(e, { ...data, x: data.x + left, y: data.y + top }); + } } From 6e7f60cf46bcb0d021b3bcd5123bb4df7e176ffd Mon Sep 17 00:00:00 2001 From: Josh Chen Date: Fri, 28 Aug 2020 21:06:10 -0700 Subject: [PATCH 2/2] Update index.tsx fix typo --- src/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index c8f514d5..5f0b9f4a 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -360,10 +360,9 @@ export class Rnd extends React.PureComponent { onDrag(e: RndDragEvent, data: DraggableData) { if (this.props.onDrag) { - // const offset = this.offsetFromParent; - // return this.props.onDrag(e, { ...data, x: data.x - offset.left, y: data.y - offset.top }); - const { left, top } = this.offsetFromParent; - return this.props.onDragStop(e, { ...data, x: data.x + left, y: data.y + top }); + const offset = this.offsetFromParent; + // return this.props.onDrag(e, { ...data, x: data.x - offset.left, y: data.y - offset.top }); + return this.props.onDragStop(e, { ...data, x: data.x + offset.left, y: data.y + offset.top }); } }