Skip to content

Commit 41a2ad0

Browse files
authoredDec 25, 2024··
fix: 修复切换到 4k 显示器时渲染模糊的问题 (#3051)
1 parent da7d9e5 commit 41a2ad0

File tree

1 file changed

+8
-3
lines changed
  • packages/s2-core/src/ui/hd-adapter

1 file changed

+8
-3
lines changed
 

‎packages/s2-core/src/ui/hd-adapter/index.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export class HdAdapter {
1717

1818
private spreadsheet: SpreadSheet;
1919

20-
private isDevicePixelRatioChange = false;
20+
private isDevicePixelRatioChange;
2121

2222
private zoomOffsetLeft: number | undefined;
2323

2424
constructor(spreadsheet: SpreadSheet) {
2525
this.spreadsheet = spreadsheet;
26+
this.isDevicePixelRatioChange = false;
27+
this.zoomOffsetLeft = 0;
2628
}
2729

2830
public init = () => {
@@ -146,10 +148,13 @@ export class HdAdapter {
146148
* 如果是触控板双指缩放触发的 resize 事件, offsetLeft 可以获取到值
147149
* 如果是浏览器窗口的放大缩小 (command +/-), offsetLeft 始终是 0
148150
*/
149-
const isTouchPadZoom = this.zoomOffsetLeft !== target.offsetLeft;
151+
const isTouchPadZoom =
152+
(this.zoomOffsetLeft || 0) !== (target?.offsetLeft || 0);
150153

151154
if (ratio >= 1 && isTouchPadZoom && !this.isDevicePixelRatioChange) {
152-
await this.renderByDevicePixelRatio(ratio);
155+
const maxDPR = Math.max(ratio, window.devicePixelRatio);
156+
157+
await this.renderByDevicePixelRatio(maxDPR);
153158
this.zoomOffsetLeft = target.offsetLeft;
154159
}
155160
}, 350);

0 commit comments

Comments
 (0)
Please sign in to comment.