js-draw 1.11.1 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -591,7 +591,8 @@ class Editor {
591
591
  return false;
592
592
  }
593
593
  // Position of the current event.
594
- const currentPos = math_1.Vec2.of(event.pageX, event.pageY);
594
+ // jsdom doesn't seem to support pageX/pageY -- use clientX/clientY if unavailable
595
+ const currentPos = math_1.Vec2.of(event.pageX ?? event.clientX, event.pageY ?? event.clientY);
595
596
  const pointerId = event.pointerId ?? 0;
596
597
  // Whether to send the current event to the editor
597
598
  let sendToEditor = true;
@@ -601,6 +602,7 @@ class Editor {
601
602
  gestureData[pointerId] = {
602
603
  eventBuffer: [[eventName, event]],
603
604
  startPoint: currentPos,
605
+ hasMovedSignificantly: false,
604
606
  };
605
607
  // Capture the pointer so we receive future events even if the overlay is hidden.
606
608
  this.setPointerCapture(elem, event.pointerId);
@@ -613,7 +615,7 @@ class Editor {
613
615
  // Skip if the pointer hasn't moved enough to not be a "click".
614
616
  const strokeStartThreshold = 10;
615
617
  const isWithinClickThreshold = gestureStartPos && currentPos.minus(gestureStartPos).magnitude() < strokeStartThreshold;
616
- if (isWithinClickThreshold) {
618
+ if (isWithinClickThreshold && !gestureData[pointerId].hasMovedSignificantly) {
617
619
  eventBuffer.push([eventName, event]);
618
620
  sendToEditor = false;
619
621
  }
@@ -623,6 +625,7 @@ class Editor {
623
625
  this.handleHTMLPointerEvent(eventName, event);
624
626
  }
625
627
  gestureData[pointerId].eventBuffer = [];
628
+ gestureData[pointerId].hasMovedSignificantly = true;
626
629
  sendToEditor = true;
627
630
  }
628
631
  }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- number: '1.11.1',
4
+ number: '1.11.2',
5
5
  };
@@ -562,7 +562,8 @@ export class Editor {
562
562
  return false;
563
563
  }
564
564
  // Position of the current event.
565
- const currentPos = Vec2.of(event.pageX, event.pageY);
565
+ // jsdom doesn't seem to support pageX/pageY -- use clientX/clientY if unavailable
566
+ const currentPos = Vec2.of(event.pageX ?? event.clientX, event.pageY ?? event.clientY);
566
567
  const pointerId = event.pointerId ?? 0;
567
568
  // Whether to send the current event to the editor
568
569
  let sendToEditor = true;
@@ -572,6 +573,7 @@ export class Editor {
572
573
  gestureData[pointerId] = {
573
574
  eventBuffer: [[eventName, event]],
574
575
  startPoint: currentPos,
576
+ hasMovedSignificantly: false,
575
577
  };
576
578
  // Capture the pointer so we receive future events even if the overlay is hidden.
577
579
  this.setPointerCapture(elem, event.pointerId);
@@ -584,7 +586,7 @@ export class Editor {
584
586
  // Skip if the pointer hasn't moved enough to not be a "click".
585
587
  const strokeStartThreshold = 10;
586
588
  const isWithinClickThreshold = gestureStartPos && currentPos.minus(gestureStartPos).magnitude() < strokeStartThreshold;
587
- if (isWithinClickThreshold) {
589
+ if (isWithinClickThreshold && !gestureData[pointerId].hasMovedSignificantly) {
588
590
  eventBuffer.push([eventName, event]);
589
591
  sendToEditor = false;
590
592
  }
@@ -594,6 +596,7 @@ export class Editor {
594
596
  this.handleHTMLPointerEvent(eventName, event);
595
597
  }
596
598
  gestureData[pointerId].eventBuffer = [];
599
+ gestureData[pointerId].hasMovedSignificantly = true;
597
600
  sendToEditor = true;
598
601
  }
599
602
  }
@@ -1,3 +1,3 @@
1
1
  export default {
2
- number: '1.11.1',
2
+ number: '1.11.2',
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-draw",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript. ",
5
5
  "types": "./dist/mjs/lib.d.ts",
6
6
  "main": "./dist/cjs/lib.js",
@@ -86,5 +86,5 @@
86
86
  "freehand",
87
87
  "svg"
88
88
  ],
89
- "gitHead": "695cfe01116839842668233a14fa858ad4ae0bac"
89
+ "gitHead": "e1d593def957ec85633ff89166f9af25ae03f862"
90
90
  }