agilgur5 / react-signature-canvas

A React wrapper component around signature_pad (in < 150 LoC). Unopinionated and heavily updated fork of react-signature-pad

Home Page:https://agilgur5.github.io/react-signature-canvas/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Width and Height change cause de-sync

liljosi opened this issue · comments

If you change the height and width using a css class it just zooms in the canvas and the pointer is defaced, but when you change it using the width and height props it works correctly, but clears the canvas every time i change the size when i implement a onMouseOver and onMouseOut.

If you change the height and width using a css class it just zooms in the canvas and the pointer is defaced

I'm not sure what you mean by "pointer is defaced", the demo uses a CSS class and does not set width or height props. CSS does scale the rendered area, but this is not necessarily problematic. I don't know how you're using it, as you did not provide a reproduction.
If you're changing the size though, that will distort the Canvas; it's not really meant to be resized, as per the below

clears the canvas every time i change the size

This is behavior of the Canvas API, and not specific to react-signature-canvas (or signature_pad). When the canvas's size is changed, it clears all content per the Canvas API spec, which states (emphasis mine):

When the user [...] set[s] [...] width and height, it must run these steps:
[...]

  • Resize the output bitmap to the new width and height and clear it to transparent black.

There is a clearOnResize prop in react-signature-canvas, but that is related to window resizes, which does not seem to be the topic of your issue. You didn't include a reproduction though