Skip to content

Commit

Permalink
fix: 修复表格卸载后, 高清适配逻辑还会触发的问题 (#2965)
Browse files Browse the repository at this point in the history
* feat: hdAdapter 销毁后添加 destroyed 标识,避免因 resize 事件的异步处理器在执行时报错

* fix: renderByDevicePixelRatio 方法中的销毁状态判断提前到 L#116 行

* fix: spreadsheet.destroyed 修改为 public

---------

Co-authored-by: linwrui <[email protected]>
  • Loading branch information
linwrui and linwrui authored Nov 8, 2024
1 parent e759891 commit c837efe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export abstract class SpreadSheet extends EE {
/**
* 表格是否已销毁
*/
private destroyed = false;
public destroyed = false;

protected abstract bindEvents(): void;

Expand Down
8 changes: 8 additions & 0 deletions packages/s2-core/src/ui/hd-adapter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class HdAdapter {
private renderByDevicePixelRatio = async (
ratio = window.devicePixelRatio,
) => {
if (this.spreadsheet.destroyed) {
return;
}

const {
container,
options: { width, height },
Expand All @@ -130,6 +134,10 @@ export class HdAdapter {
};

private renderByZoomScale = debounce(async (event: Event) => {
if (this.spreadsheet.destroyed) {
return;
}

const target = event.target as VisualViewport;
const ratio = Math.ceil(target?.scale);

Expand Down

0 comments on commit c837efe

Please sign in to comment.