Skip to content

Commit

Permalink
fix: update resizer size when scaling the page
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Sep 3, 2024
1 parent 753510b commit 2351855
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/editor/core/draw/particle/previewer/Previewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ export class Previewer {
}

private _createResizerDom(): IPreviewerCreateResult {
const { scale } = this.options
// 拖拽边框
const resizerSelection = document.createElement('div')
resizerSelection.classList.add(`${EDITOR_PREFIX}-resizer-selection`)
resizerSelection.style.display = 'none'
resizerSelection.style.borderColor = this.options.resizerColor
resizerSelection.style.borderWidth = `${scale}px`
// 拖拽点
const resizerHandleList: HTMLDivElement[] = []
for (let i = 0; i < 8; i++) {
Expand Down Expand Up @@ -386,7 +388,7 @@ export class Previewer {
}

public _updateResizerRect(width: number, height: number) {
const handleSize = this.options.resizerSize
const { resizerSize: handleSize, scale } = this.options
this.resizerSelection.style.width = `${width}px`
this.resizerSelection.style.height = `${height}px`
// handle
Expand All @@ -403,6 +405,7 @@ export class Previewer {
: i === 3 || i === 7
? height / 2 - handleSize
: height - handleSize
this.resizerHandleList[i].style.transform = `scale(${scale})`
this.resizerHandleList[i].style.left = `${left}px`
this.resizerHandleList[i].style.top = `${top}px`
}
Expand Down Expand Up @@ -447,6 +450,7 @@ export class Previewer {
)
this.resizerSelection.style.left = `${resizerLeft}px`
this.resizerSelection.style.top = `${resizerTop}px`
this.resizerSelection.style.borderWidth = `${scale}px`
// 更新预览包围框尺寸
this._updateResizerRect(elementWidth, elementHeight)
this.resizerSelection.style.display = 'block'
Expand Down

0 comments on commit 2351855

Please sign in to comment.