Skip to content

Commit

Permalink
Scale canvas properly when using responsive mode
Browse files Browse the repository at this point in the history
Fixes #101
  • Loading branch information
drewnoakes committed Apr 20, 2018
1 parent 0442d95 commit 15a0e2f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions smoothie.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,12 @@
if (width !== this.lastWidth) {
this.lastWidth = width;
this.canvas.setAttribute('width', (Math.floor(width * dpr)).toString());
this.canvas.getContext('2d').scale(dpr, dpr);
}
if (height !== this.lastHeight) {
this.lastHeight = height;
this.canvas.setAttribute('height', (Math.floor(height * dpr)).toString());
this.canvas.getContext('2d').scale(dpr, dpr);
}
} else if (dpr !== 1) {
// Older behaviour: use the canvas's inner dimensions and scale the element's size
Expand Down

0 comments on commit 15a0e2f

Please sign in to comment.