Skip to content

Commit

Permalink
feat:asyncTranslate
Browse files Browse the repository at this point in the history
  • Loading branch information
ananzhusen committed Dec 19, 2024
1 parent 6e092d7 commit 782d45f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/core/src/canvas/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5053,6 +5053,7 @@ export class Canvas {
ctx.restore();
};

transTimeout: any;
translate(x: number = 0, y: number = 0) {
this.store.data.x += x * this.store.data.scale;
this.store.data.y += y * this.store.data.scale;
Expand Down Expand Up @@ -5106,10 +5107,20 @@ export class Canvas {
}
//TODO 当初为什么加异步
// setTimeout(() => {
if(this.store.data.asyncTranslate){
clearTimeout(this.transTimeout);
this.transTimeout = setTimeout( ()=> {
this.canvasTemplate.init();
this.canvasImage.init();
this.canvasImageBottom.init();
this.render();
}, 300);
}else{
this.canvasTemplate.init();
this.canvasImage.init();
this.canvasImageBottom.init();
this.render();
}
// });
this.store.emitter.emit('translate', {
x: this.store.data.x,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface Meta2dData {
fits?: Fit[];
disableTranslate?: boolean; //禁止平移
disableScale?: boolean; //禁止缩放
asyncTranslate?: boolean; //异步平移
}

export interface Fit {
Expand Down

0 comments on commit 782d45f

Please sign in to comment.