From bb63eeb335e45899cf5b6906f26fc1bb7599356e Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Tue, 14 Mar 2023 22:01:39 +0800 Subject: [PATCH] fix:init page context when paper change --- src/editor/core/draw/Draw.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index ce2521b..54acb79 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -504,15 +504,12 @@ export class Draw { const height = this.getHeight() this.container.style.width = `${width}px` this.pageList.forEach((p, i) => { - p.width = width - p.height = height + p.width = width * dpr + p.height = height * dpr p.style.width = `${width}px` p.style.height = `${height}px` p.style.marginBottom = `${this.getPageGap()}px` - // 分辨率 - p.width = width * dpr - p.height = height * dpr - this.ctxList[i].scale(dpr, dpr) + this._initPageContext(this.ctxList[i]) }) this.render({ isSubmitHistory: false, @@ -530,7 +527,7 @@ export class Draw { this.pageList.forEach((p, i) => { p.width = width * dpr p.height = height * dpr - this.ctxList[i].scale(dpr, dpr) + this._initPageContext(this.ctxList[i]) }) this.render({ isSubmitHistory: false, @@ -539,14 +536,16 @@ export class Draw { } public setPaperSize(width: number, height: number) { + const dpr = window.devicePixelRatio this.options.width = width this.options.height = height this.container.style.width = `${width}px` - this.pageList.forEach(p => { - p.width = width - p.height = height + this.pageList.forEach((p, i) => { + p.width = width * dpr + p.height = height * dpr p.style.width = `${width}px` p.style.height = `${height}px` + this._initPageContext(this.ctxList[i]) }) this.render({ isSubmitHistory: false,