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

Move clear to after resize so if height and width are calculated the … #1

Closed randallknutson closed 7 years ago

randallknutson commented 8 years ago

…background color gets set on the initial render.

When testing, if I didn't set a height and width and instead relied on offsetHeight and offsetWidth, the background color would not be set until the clear function was called manually. I think this is because in componentDidMount you were calling this.clear() before this._resizeCanvas() so the canvas didn't have any area to clear yet. Moving the clear to after resizeCanvas fixed the issue for me.

agilgur5 commented 7 years ago

Oh wow great catch -- thanks for the contribution! Rebased in as 729d505a8a558feeadcbfa1739e97358276932fc

Sorry for the delayed response -- apparently I wasn't "watching" my own repositories for the longest time :(