Skip to content

Commit

Permalink
Allow custom ratio/width/height in fromDataURL (#253)
Browse files Browse the repository at this point in the history
Can pass in custom ratio and size to fromDataURL
  • Loading branch information
halo authored and szimek committed Jun 11, 2017
1 parent 7326284 commit faf4cf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## Changelog

### master

* Allow custom ratio/width/height when loading data URL onto canvas

### 2.1.1
* Fixed a bug where default value was applied for throttle when throttle was set to 0. ([mkrause](https://github.com/mkrause) in [#247](https://github.com/szimek/signature_pad/pull/247))

Expand Down
8 changes: 4 additions & 4 deletions src/signature_pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ SignaturePad.prototype.clear = function () {
this._isEmpty = true;
};

SignaturePad.prototype.fromDataURL = function (dataUrl) {
SignaturePad.prototype.fromDataURL = function (dataUrl, options = {}) {
const image = new Image();
const ratio = window.devicePixelRatio || 1;
const width = this._canvas.width / ratio;
const height = this._canvas.height / ratio;
const ratio = options.ratio || window.devicePixelRatio || 1;
const width = options.width || (this._canvas.width / ratio);
const height = options.height || (this._canvas.height / ratio);

this._reset();
image.src = dataUrl;
Expand Down

0 comments on commit faf4cf7

Please sign in to comment.