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

onDrawEnd doesn't fire for touch events #92

Closed
ragingchikn opened this issue Sep 5, 2013 · 3 comments
Closed

onDrawEnd doesn't fire for touch events #92

ragingchikn opened this issue Sep 5, 2013 · 3 comments
Labels

Comments

@ragingchikn
Copy link

touchend and touchcancel events pass in an event arg to the stopDrawing function. This causes drawLine to be called, and the onDrawEnd.apply call is skipped over. Because of this, onDrawEnd is not fired on touch enabled devices.

@thomasjbradley
Copy link
Contributor

That is definitely a bug. I'll look into it and get back to you.

@ezl
Copy link

ezl commented Sep 21, 2013

@ragingchikn thanks for bringing this up.

I did this :

   function stopDrawing (e) {
-    if (!!e) {
+    if (!!e && !(e.type === "touchend" || e.type == "touchcancel")) {
       drawLine(e, 1)
     } else {

Basically:

  1. all the touch events are bound using .addEventListener (https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener) who is calling the stopDrawing method and always passing the event
  2. all the mouse events are bound and the stopDrawing method is called explicitly where signature-pad can opt to pass the event or not.

So for the mouse events is fine to just test for existence of the passed event and use that as a way to figure out if the mouse just left the canvas or if they user actually lifted the mouse.

For the touch events, they all look the same (event exists) so instead, I just explicitly checked for the 2 touch events where I would WANT to call the drawEnd stuff.

Edit: I initially screwed that up like this. Fixed.

@thomasjbradley
Copy link
Contributor

I've fixed this problem now with version 2.4.2.

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

No branches or pull requests

3 participants