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 not working Google Chrome, mobile devices (width >= 1080) #426

Closed
cristhianDt opened this issue Mar 18, 2019 · 7 comments
Closed

Comments

@cristhianDt
Copy link

Hi,

First thank you for your work.

Secondly, I have a problem with some mobile devices (smart phones and tablets) of width greater than or equal to 1080 pixels (like HTC M9 Plus, Moto g (6) and Moto g5 Plus, Samsung SM-T385M). In these devices the signature doesn't work, when I try to sign, the page do a scroll (up or down) and only draw a point into the canvas (look the image). The issue only happen in Google Chrome, in Firefox works fine (with one or more signatures). In other case with more than one signature, only the first signature works and the others doesn't work -Google Chrome-.

Signature-pad Error

Watching the browser console I found this error:
[Intervention] Ignored attempt to cancel a touch event with cancelable = false, for example because scrolling is in progress and cannot be interrupted signature-pad.js:63

In this line:
this._handleTouchEnd = function (event) { var wasCanvasTouched = event.target === self._canvas; if (wasCanvasTouched) { event.preventDefault(); self._strokeEnd(event); } };

I changed it to:
this._handleTouchEnd = function (event) { var wasCanvasTouched = event.target === self._canvas; if (wasCanvasTouched && event.cancelable) { event.preventDefault(); self._strokeEnd(event); } };

The error in the console stopped to appearing, but the signature not working yet. I tried with version 2.3.0 and does not work either.

Maybe do you have any idea about it?. Thanks.

@szimek
Copy link
Owner

szimek commented Mar 18, 2019

I got no idea why it might be happening. Could you add a listener for scroll event and see if the error message is right, i.e. there's "scrolling in progress"?

BTW. Could you set up a demo somewhere? I've got Android tablet, which probably has resolution higher than 1080.

@cristhianDt
Copy link
Author

Sorry for the delay.

Yes, I can.

Let me see if I can set up a demo for you.

@cristhianDt
Copy link
Author

cristhianDt commented Mar 20, 2019

@szimek ,

Codepen:

I added a listener for scroll event, "scrolling" open the browser console.

@cristhianDt
Copy link
Author

@szimek

@cristhianDt
Copy link
Author

Hi,

Have you been able to check it? @szimek :C

@Steeveuk
Copy link

Steeveuk commented Apr 26, 2019

Hi,

I had this same issue, I think I've fixed it by implementing the following within an on window load & window resize function (I am also using jQuery):

$('canvas.sig_canvas').each(function(){
  var id = $(this).attr('id'); //Get the ID of signature
  var width = $(this).closest('.sig_container').width(); //Get the width of the signature container
  sig_pads[id].off(); //Unbind all events on signature pad (I have an array of them)

  if(!$(this).data('prev_width') || Math.abs(width - $(this).data('prev_width')) > 30){ //Resize threshold 30px, only resize if previous width has changed by 30 pxs
    var ctx = $(this)[0].getContext('2d'); //Get context
    $(this).attr('width', width); //Set canvas width
    ctx.canvas.width  = width; //Set context width
    $(this).data('prev_width', width); //Update prev_width for threshold
  }
  sig_pads[id].on(); //Rebind all signature events
});

I am not sure if it was unbinding and rebinding or if it was setting a canvas width as well as context width that seems to have fixed it.

Hope this helps you.

@DvirH
Copy link

DvirH commented May 14, 2019

According to @Steeveuk things, Just use the SignaturePadInstance.off() and re enable by SignaturePadInstance.on()

@UziTech UziTech closed this as completed Jun 19, 2021
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

5 participants