diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d7ec20d..1bd177cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/signature_pad.js b/src/signature_pad.js index 614def2b..dc58bf06 100644 --- a/src/signature_pad.js +++ b/src/signature_pad.js @@ -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;