thread-pond / signature-pad

A jQuery plugin for assisting in the creation of an HTML5 canvas based signature pad. Records the drawn signature in JSON for later regeneration.
BSD 3-Clause "New" or "Revised" License
727 stars 292 forks source link

Styling mismatch can cause infinite loop when using type-it functionality #216

Closed cmcgee-mac closed 3 years ago

cmcgee-mac commented 3 years ago

When using signature-pad with custom styling the page locks up after typing in the name field in type-it mode. A difference in styling should never cause this kind of behaviour.

The cause is in this part of the code that appears to be trying to shrink the font size until the typed div becomes smaller in width than the pad so that it fits. When invalid styling is applied this loop will go on forever since the typed div isn't shrinking in width by adjusting the font size.

https://github.com/thread-pond/signature-pad/blob/7e22e673255a7d08e901a5b2be6225ea2e555a1a/jquery.signaturepad.js#L531

Instead, there should be some kind of limiter on this, perhaps some global minimum font size, at least disallow zero or negative?

mockdeep commented 3 years ago

@cmcgee-mac makes sense. If you make a PR, I'll be happy to merge it.

cmcgee-mac commented 3 years ago

Sure, I've raised this one as a starting point. https://github.com/thread-pond/signature-pad/pull/217