agilgur5 / react-signature-canvas

A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad
https://agilgur5.github.io/react-signature-canvas/
Other
547 stars 119 forks source link

when loading fromDataURL, resize canvas before drawing image on canvas #10

Closed r-huang closed 5 years ago

r-huang commented 7 years ago

6

Have the canvas resize before drawing the canvas, will properly scale the image.

agilgur5 commented 7 years ago

Wouldn't not dividing the width and height by the ratio when drawing the image (just setting it canvas.width and canvas.height) do the same thing? The resize multiplies the width and height by ratio, so it seems like they're just cancelling each other out.

Just removing the division would also be a lot better than adding a resize as that's a new side effect with potentially unexpected bugs as a result

agilgur5 commented 5 years ago

Revisited this recently. Going to close this out due to inactivity and since it no longer applies to the current repo as fromDataURL is now implemented by the upstream signature_pad as of v1.0.0. The upstream fix mentioned in https://github.com/agilgur5/react-signature-canvas/issues/6#issuecomment-380652924 also resolves the same issue this resolves.

I'm also still unsure that resizing the canvas is the right fix, due to aforementioned side effects, as well as because resizeCanvas is already called once on componentDidMount (and has been since before this fork began)