Skip to content

Commit

Permalink
Hopefully really fix SignaturePad#fromDataURL on HiDPI screens this time
Browse files Browse the repository at this point in the history
  • Loading branch information
szimek committed Nov 21, 2014
1 parent 3f5452e commit a8add8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/signature_pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var SignaturePad = (function (document) {
SignaturePad.prototype.fromDataURL = function (dataUrl) {
var self = this,
image = new Image(),
ratio = window.devicePixelWidth || 1,
ratio = window.devicePixelRatio || 1,
width = this._canvas.width / ratio,
height = this._canvas.height / ratio;

Expand Down

6 comments on commit a8add8d

@webismymind
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thanks for this nice library! I'm using it on an iPad Retina and I noticed that fromDataUrl was loading the image 2x smaller than expected. I noticed this commit, and tried undoing the modification, and it now works correctly for me. Do you know what is happening here ? Is this correction somehow not good or am I missing something ?

Kind regards,
Louis

@szimek
Copy link
Owner Author

@szimek szimek commented on a8add8d Feb 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh... when exactly does it happen? Do you create and then read back the signature on the same device? I got 2 Macs with retina and non-retina screens, so I'll try to come up with all possible test cases I can think of (i.e. create images on non-retina and retina screens and then read it back on non-retina and retina) and see if it works...

@szimek
Copy link
Owner Author

@szimek szimek commented on a8add8d Feb 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webismymind could you try out this fiddle http://jsfiddle.net/szimek/baL7r8xd/2? Draw anything, cick/tap "replace" button and check if the result is the same as drawn image. There's also similar issue already reported #89...

@szimek
Copy link
Owner Author

@szimek szimek commented on a8add8d Feb 14, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webismymind Please check #89 (comment) and try if the tests I prepared work for you.

@webismymind
Copy link

@webismymind webismymind commented on a8add8d Feb 17, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szimek
Copy link
Owner Author

@szimek szimek commented on a8add8d Feb 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange :) I prepared 2 tests (linked in #89 (comment)) and they both work fine on 2 Macs with different devicePixelRatio (1 and 2).

Please sign in to comment.