Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom ratio/width/height in fromDataURL #253

Merged
merged 2 commits into from
Jun 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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