Skip to content

Commit

Permalink
fix: prevent multiply pointers drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
wokayme committed Aug 30, 2024
1 parent 267935b commit ee51892
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/signature_pad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ export default class SignaturePad extends SignatureEventTarget {
};

private _handlePointerDown = (event: PointerEvent): void => {
if (!this._isLeftButtonPressed(event) || this._drawingStroke) {
if (
!event.isPrimary ||
!this._isLeftButtonPressed(event) ||
this._drawingStroke
) {
return;
}

Expand All @@ -386,7 +390,11 @@ export default class SignaturePad extends SignatureEventTarget {
};

private _handlePointerMove = (event: PointerEvent): void => {
if (!this._isLeftButtonPressed(event, true) || !this._drawingStroke) {
if (
!event.isPrimary ||
!this._isLeftButtonPressed(event, true) ||
!this._drawingStroke
) {
// Stop when primary button not pressed or multiple buttons pressed
this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
return;
Expand Down

0 comments on commit ee51892

Please sign in to comment.