diff --git a/packages/base/src/component.ts b/packages/base/src/component.ts index 8c42a2cd..19e769e3 100644 --- a/packages/base/src/component.ts +++ b/packages/base/src/component.ts @@ -330,7 +330,7 @@ export class CustomComponent { const positionKey = ['top', 'left', 'height', 'width', 'rotate'] let changeValue = value if (propKeys[0] === 'position') { - if ((propKeys.length === 2, positionKey.includes(propKeys[1]))) { + if (propKeys.length === 2 && positionKey.includes(propKeys[1])) { changeValue = Math.round(value) this.positionStyle[propKeys[1]] = changeValue } else if (propKeys.length === 1) { diff --git a/packages/designer/src/editor/Editor.vue b/packages/designer/src/editor/Editor.vue index 5334dc8c..0d761efa 100644 --- a/packages/designer/src/editor/Editor.vue +++ b/packages/designer/src/editor/Editor.vue @@ -249,8 +249,8 @@ const handleDrop = async (e) => { } const editorRectInfo = document.querySelector('#editor')!.getBoundingClientRect() - const y = (e.pageY - editorRectInfo.top) / canvasState.scale - const x = (e.pageX - editorRectInfo.left) / canvasState.scale + const y = Math.round((e.pageY - editorRectInfo.top) / canvasState.scale) + const x = Math.round((e.pageX - editorRectInfo.left) / canvasState.scale) component.changeStyle(['position', 'top'], y) component.changeStyle(['position', 'left'], x) canvasState.appendComponent(component)