Skip to content

Commit

Permalink
perf: update canvas size only when the window is resized
Browse files Browse the repository at this point in the history
  • Loading branch information
fand committed Jul 3, 2020
1 parent e500c1e commit fbdbb04
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/vfx-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ export default class VFXPlayer {
if (typeof window !== "undefined") {
const w = window.innerWidth;
const h = window.innerHeight;
this.canvas.width = w;
this.canvas.height = h;
this.renderer.setSize(w, h);
this.renderer.setPixelRatio(this.pixelRatio);
this.w = w;
this.h = h;

if (w !== this.w || h !== this.h) {
this.canvas.width = w;
this.canvas.height = h;
this.renderer.setSize(w, h);
this.renderer.setPixelRatio(this.pixelRatio);
this.w = w;
this.h = h;
}
}
}

Expand Down

0 comments on commit fbdbb04

Please sign in to comment.