Skip to content

Commit

Permalink
Merge pull request #116 from adroitwhiz/zero-size
Browse files Browse the repository at this point in the history
Don't draw if one of the canvas dimensions is 0
  • Loading branch information
fsih committed Jan 9, 2020
2 parents 3b39cb0 + 1949564 commit ec35ed3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/svg-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ class SvgRenderer {
const bbox = this._measurements;
this._canvas.width = bbox.width * ratio;
this._canvas.height = bbox.height * ratio;
if (this._canvas.width <= 0 || this._canvas.height <= 0) return;
this._context.clearRect(0, 0, this._canvas.width, this._canvas.height);
this._context.scale(ratio, ratio);
this._context.drawImage(this._cachedImage, 0, 0);
Expand Down

0 comments on commit ec35ed3

Please sign in to comment.