jakubfiala / atrament

A small JS library for beautiful drawing and handwriting on the HTML Canvas.
http://fiala.space/atrament/demo
MIT License
1.56k stars 115 forks source link

Problems with hand-down on iPad with apple pencil #53

Closed jnsglmllr closed 8 months ago

jnsglmllr commented 4 years ago

First off - great stuff. Thank you!

I am having trouble on using atrament.js on an iPad Pro with Apple Pencil. While writing the wrist-detection seems to have some difficulties during the way so a moosdown is simulated where my wrist is again and again. So when I write a sentence I get like 10 straight strokes on my canvas.

I guess some kind of test has to be run if the new mouseDown is done before an mouseUp is triggered and ignore that in that case.

Best Jonas

jakubfiala commented 4 years ago

hey @jnsglmllr, thanks for reporting this issue! This is indeed most likely because Atrament always uses the latest "changed touch" to draw, so we'll have to fix that. Will look into it as soon as I can, otherwise feel free to submit a PR :)

jnsglmllr commented 3 years ago

Hey @jakubfiala! Did you already have time to look into this issue? Thanks a lot 👍

jakubfiala commented 3 years ago

hey @jnsglmllr - really sorry, somehow I didn't get round to it. It's partly because I don't own an iPad I could test it on. I do think it should be possible to fix by keeping track of the first registered Touch object on mouse down, and only considering the mousemove event if the changedTouches array contains this Touch.

I would encourage you to try it and make a pull request if you have time - otherwise I'll look into it as soon as possible.

jakubfiala commented 9 months ago

I suspect this issue may be solved via 8610db6 - according to the Pointer Events spec, the isPrimary property is expected to be true only for pen inputs in devices which support palm rejection:

Some devices, operating systems and user agents may ignore the concurrent use of more than one type of pointer input to avoid accidental interactions. For instance, devices that support both touch and pen interactions may ignore touch inputs while the pen is actively being used, to allow users to rest their hand on the touchscreen while using the pen (a feature commonly referred to as "palm rejection"). Currently, it is not possible for authors to suppress this behavior.

It seems like the iPad does support this. In a few weeks I'll have access to an iPad + Pencil and will be able to confirm that the migration to Pointer Events and filtering for the primary event fixes this issue. If it does, then the fix can be expected to ship with v4.0.0

jakubfiala commented 8 months ago

@jnsglmllr I'm almost 4 years too late but can confirm this issue will be resolved in v4.0.0 which i'm going to release in the next week or so.