Skip to content

Commit

Permalink
fix: 修復了坐标为小数的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsGoo committed May 12, 2024
1 parent 679ae31 commit 16bcc88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/base/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/designer/src/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16bcc88

Please sign in to comment.