Skip to content

Commit

Permalink
Add restore of canvas after resize (szimek/signature_pad#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbachergon committed May 2, 2016
1 parent 256f4f3 commit 53d82c2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/signature.js
Expand Up @@ -61,11 +61,13 @@ angular.module('signature').directive('signaturePad', ['$window',
}

scope.onResize = function() {
var data = scope.signaturePad.toDataURL();
var canvas = element.find('canvas')[0];
var ratio = Math.max($window.devicePixelRatio || 1, 1);
canvas.width = canvas.offsetWidth * ratio;
canvas.height = canvas.offsetHeight * ratio;
canvas.getContext("2d").scale(ratio, ratio);
scope.signaturePad.fromDataURL(data);
}

scope.onResize();
Expand Down

0 comments on commit 53d82c2

Please sign in to comment.