From 1da500d98828a802940d10bf10b23ced46520317 Mon Sep 17 00:00:00 2001 From: Carlos Date: Wed, 19 Mar 2025 21:14:54 -0700 Subject: [PATCH] fix: cleanup --- .../core/src/commands/view/ComponentDrag.ts | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/core/src/commands/view/ComponentDrag.ts b/packages/core/src/commands/view/ComponentDrag.ts index 690b8dcff..1d3f07c43 100644 --- a/packages/core/src/commands/view/ComponentDrag.ts +++ b/packages/core/src/commands/view/ComponentDrag.ts @@ -213,7 +213,7 @@ export default { if (!el.children.length) { numEl = document.createElement('div'); - numEl.style = `position: absolute; color: red}; padding: 5px; top: 0; left: 0;`; + numEl.style = 'position: absolute; color: red; padding: 5px; top: 0; left: 0;'; el.appendChild(numEl); } @@ -349,9 +349,6 @@ export default { opts?.onStart?.(this._getDragData()); if (isTran) return; - let x = 0; - let y = 0; - if (style.position !== position) { let { left, top, width, height } = Canvas.offset(target.getEl()); let parent = target.parent(); @@ -375,12 +372,9 @@ export default { top = top - offsetP.top; } - x = left; - y = top; - this.setPosition({ - x, - y, + x: left, + y: top, width: `${width}px`, height: `${height}px`, position, @@ -388,7 +382,7 @@ export default { } this.editor.trigger(`${evName}:drag:start`, { - coords: { x, y }, + coords: { x: 0, y: 0 }, // TODO: pass the real coords component: target, componentView: target.view, styles: style, @@ -408,10 +402,8 @@ export default { this.updateGuides(guidesTarget); opts?.debug && guidesTarget.forEach((item: any) => this.renderGuide(item)); - if (opts?.guidesInfo) { - guideNearElements = this.renderGuideInfo(guidesTarget.filter((item: any) => item.active)); - } - opts?.onDrag?.(this._getDragData()); + opts?.guidesInfo && (guideNearElements = this.renderGuideInfo(guidesTarget.filter((item: any) => item.active))); + opts?.onDrag && opts.onDrag(this._getDragData()); const { x, y } = mouseEvent; this.editor.trigger(`${evName}:drag:move`, { coords: { x, y }, guideNearElement: guideNearElements[0] }); @@ -533,9 +525,3 @@ export default { [k: string]: any; } >; - -function styleObjectToString(style: HTMLElement['style']): string { - return Object.entries(style) - .map(([key, value]) => `${key}: ${value}`) - .join('; '); -}