From 54436b0a4710946482971ab088bfa809568ff268 Mon Sep 17 00:00:00 2001 From: newbyvector Date: Thu, 5 Oct 2023 16:34:16 +0800 Subject: [PATCH] fix: subtract draggingContainer offset when position --- packages/x6-plugin-dnd/src/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/x6-plugin-dnd/src/index.ts b/packages/x6-plugin-dnd/src/index.ts index aceb26f1561..2138571ca98 100644 --- a/packages/x6-plugin-dnd/src/index.ts +++ b/packages/x6-plugin-dnd/src/index.ts @@ -182,10 +182,18 @@ export class Dnd extends View implements Graph.Plugin { } if (this.draggingGraph) { - Dom.css(this.container, { - left: `${offset.left}px`, - top: `${offset.top}px`, - }) + if (this.options.draggingContainer) { + const { top, left } = Dom.offset(this.options.draggingContainer) + Dom.css(this.container, { + left: `${offset.left - left}px`, + top: `${offset.top - top}px`, + }) + } else { + Dom.css(this.container, { + left: `${offset.left}px`, + top: `${offset.top}px`, + }) + } } return offset