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

We require the signature to not overflow and break, need a continuous signature, is it possible to give an option if we need a smooth signature or broken signature in case of overflow #795

Closed
digioAbhi opened this issue Oct 16, 2024 · 5 comments

Comments

@digioAbhi
Copy link

If you have a question, please ask it on StackOverflow and use signature-pad tag instead of creating an issue.

Do you want to request a feature or report a bug?

What is the current behavior?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/szimek/h80phxyr/).

What is the expected behavior?

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

@UziTech
Copy link
Collaborator

UziTech commented Oct 16, 2024

So you don't want the signature to look like how they drew it, you just want to add lines between marks for them?

@digioAbhi
Copy link
Author

Yes, basically the behaviour before 5.0.1
like 4.2.0
overflow should be joined, consistent signatures
#765

older behaviour is what is required by me

@UziTech
Copy link
Collaborator

UziTech commented Oct 17, 2024

Why would you want to save a signature that is not actually what they drew?

@UziTech
Copy link
Collaborator

UziTech commented Oct 17, 2024

I don't think we will be reintroducing that bug. https://xkcd.com/1172/

You can use v4 if you still want that bug, or you can change the data to be within the bounds of the canvas on endStroke if you want.

Something like:

signaturePad.addEventListener("endStroke", () => {
  const data = signaturePad.toData();
  if (data && data.length > 0) {
    const width = canvas.offsetWidth;
    const height = canvas.offsetHeight;
    const lastPoints = data[data.length - 1].points;
    for (let i = 0; i < lastPoints.length; i++) {
      if (lastPoints[i].x < 0) {
        lastPoints[i].x = 0;
      }
      if (lastPoints[i].x > width) {
        lastPoints[i].x = width;
      }
      if (lastPoints[i].y < 0) {
        lastPoints[i].y = 0;
      }
      if (lastPoints[i].y > height) {
        lastPoints[i].y = height;
      }
    }
    data[data.length - 1].points = lastPoints;
  }
  signaturePad.fromData(data);
});

signaturepad_bug

@UziTech UziTech closed this as completed Oct 17, 2024
@digioAbhi
Copy link
Author

Thank you
works fine for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants