Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature pad fromData fails due to division by zero #786

Closed
samvimes01 opened this issue Aug 23, 2024 · 0 comments
Closed

Signature pad fromData fails due to division by zero #786

samvimes01 opened this issue Aug 23, 2024 · 0 comments

Comments

@samvimes01
Copy link
Contributor

Do you want to request a feature or report a bug?
Report a bug when signature is not drawn.

What is the current behavior?
Signature Pad fails to draw a signature on a canvas.
For example this signature was generated by another old library and stored in the DB (like this http://keith-wood.name/signature.html).

const points = [{"points":[{"x":54.4,"y":10.9,"color":"black","pressure":0.5},{"x":54.4,"y":10.9,"color":"black","pressure":0.5},{"x":54.2,"y":10.9,"color":"black","pressure":0.5},{"x":53.8,"y":10.9,"color":"black","pressure":0.5},{"x":52.6,"y":10.9,"color":"black","pressure":0.5},{"x":51,"y":10.9,"color":"black","pressure":0.5},{"x":49.4,"y":10.9,"color":"black","pressure":0.5},{"x":47.8,"y":11,"color":"black","pressure":0.5},{"x":46.6,"y":11.2,"color":"black","pressure":0.5},{"x":46,"y":11.7,"color":"black","pressure":0.5},{"x":45.6,"y":12.3,"color":"black","pressure":0.5},{"x":45.4,"y":13.4,"color":"black","pressure":0.5},{"x":45,"y":15,"color":"black","pressure":0.5},{"x":44.6,"y":16.7,"color":"black","pressure":0.5},{"x":44.4,"y":18.4,"color":"black","pressure":0.5},{"x":44.2,"y":20.1,"color":"black","pressure":0.5},{"x":44,"y":21.3,"color":"black","pressure":0.5},{"x":44.2,"y":22,"color":"black","pressure":0.5},{"x":44.8,"y":22.5,"color":"black","pressure":0.5},{"x":46,"y":22.8,"color":"black","pressure":0.5},{"x":48.8,"y":22.9,"color":"black","pressure":0.5},{"x":53,"y":23,"color":"black","pressure":0.5},{"x":57.6,"y":22.9,"color":"black","pressure":0.5},{"x":61.6,"y":22.7,"color":"black","pressure":0.5},{"x":64.6,"y":22,"color":"black","pressure":0.5},{"x":67,"y":21.1,"color":"black","pressure":0.5},{"x":68.8,"y":19.9,"color":"black","pressure":0.5},{"x":69.8,"y":18.8,"color":"black","pressure":0.5},{"x":70.2,"y":17.7,"color":"black","pressure":0.5},{"x":68.8,"y":14.7,"color":"black","pressure":0.5}]},{"points":[{"x":56,"y":10.5,"color":"black","pressure":0.5},{"x":56,"y":10.5,"color":"black","pressure":0.5},{"x":56.2,"y":10.5,"color":"black","pressure":0.5},{"x":58,"y":10.5,"color":"black","pressure":0.5},{"x":61,"y":10.5,"color":"black","pressure":0.5},{"x":64,"y":10.5,"color":"black","pressure":0.5},{"x":66.6,"y":10.5,"color":"black","pressure":0.5},{"x":68.8,"y":10.5,"color":"black","pressure":0.5},{"x":70,"y":10.6,"color":"black","pressure":0.5},{"x":70.6,"y":10.7,"color":"black","pressure":0.5},{"x":70.8,"y":11.1,"color":"black","pressure":0.5},{"x":71,"y":11.7,"color":"black","pressure":0.5},{"x":71.2,"y":12.4,"color":"black","pressure":0.5},{"x":71.4,"y":13.1,"color":"black","pressure":0.5},{"x":71.6,"y":13.7,"color":"black","pressure":0.5},{"x":71.8,"y":14,"color":"black","pressure":0.5}]}]

signaturePad.fromData(points) // fails

signaturePad.fromData(points) throws an error due to division by zero error.

Screenshot 2024-08-23 at 16 29 42

What is the expected behavior?
Sinature pad doesn't throw an error and draw on canvas.

Which versions of SignaturePad, and which browser / device are affected by this issue? Did this work in previous versions of SignaturePad?
Affected versions > 4.0.0

This PR proposes a fix
#785

@UziTech UziTech closed this as completed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants