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

fix: set user-select none on canvas #591

Merged
merged 3 commits into from
Jan 21, 2022

Conversation

marmooo
Copy link
Contributor

@marmooo marmooo commented Jan 17, 2022

On iOS 15, a fast double-tap will trigger an unintended pan event.
I think this is a problem caused by the loupe feature in iOS 15.
It does not occur in iOS 14.
The solution is to always turn off the pan event in the constructor,
instead of switching it in event handling.
I think there is no need to turn the pan event on/off.
Therefore, it is better to stop the pan event in the constructor
so that it is not affected by the browser implementation.

I have checked this patch on the following environments.

  • iPhone 8 (iOS 15.1) + Safari # need fixing
  • iPhone 8 (iOS 14.8.1) + Safari # not need fixing
  • MediaPad M3 Lite 10 wp (Android 7.0) + Chrome # not need fixing

I don't have Windows tablet, so I can't check ms-touch-action,
but theoretically it should work.

bug.mp4

@UziTech
Copy link
Collaborator

UziTech commented Jan 18, 2022

Are you calling .off? If you never call .off it shouldn't matter if this gets changed in the .on function or before it.

@marmooo
Copy link
Contributor Author

marmooo commented Jan 18, 2022

Yes, I have checked on http://szimek.github.io/signature_pad/.
By the way, this URL is 4.0.0, but the result is the same for local 4.0.1.
The following is what is happening in fast double-tap, I think.
This is a guess.

  1. [hand] touch start canvas
  2. [brower] check touch-action and call js (some delay)
  3. [js] call .on async functions and touch-action:none;
  4. [hand] touch end canvas
  5. [js] call .off async functions and touch-action:auto;
  6. [hand] touch start canvas
  7. [brower] check touch-action and call js (some delay)
  8. The loupe appears and skip draw line (occurs problem!)
  9. [js] call .on async functions and touch-action:none;

@UziTech
Copy link
Collaborator

UziTech commented Jan 18, 2022

I don't believe .off is ever called in https://szimek.github.io/signature_pad. Which means this wouldn't fix it.

@marmooo
Copy link
Contributor Author

marmooo commented Jan 18, 2022

Sorry, I apologize for my misunderstanding and lack of checking.
I don't know what the solution of loupe is at this point,
but the problem itself appears to remain, so I will reconsider.

The loupe will remain, but the following may be a partial solution to write a line.

this.canvas.style.userSelect = 'none';

@@ -87,6 +87,8 @@ export default class SignaturePad extends SignatureEventTarget {

this.clear();

this.canvas.style.userSelect = 'none';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the on function with the other style adjustments. Also remove this style in the off function.

@UziTech UziTech changed the title fix fast double-tap on iOS 15 fix: set user-select none on canvas Jan 21, 2022
@UziTech UziTech merged commit 59ff331 into szimek:master Jan 21, 2022
github-actions bot pushed a commit that referenced this pull request Jan 21, 2022
## [4.0.2](v4.0.1...v4.0.2) (2022-01-21)

### Bug Fixes

* set user-select none on canvas ([#591](#591)) ([59ff331](59ff331))
@github-actions
Copy link

🎉 This PR is included in version 4.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

2 participants