@woosh/meep-engine 2.33.32 → 2.33.33

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.
@@ -60,14 +60,30 @@ function forEachTouch(touchList, callback) {
60
60
  */
61
61
  function getTouchCenter(touchList, result) {
62
62
  const length = touchList.length;
63
+
63
64
  let x = 0, y = 0;
64
- for (let i = 0; i < length; i++) {
65
- const touch = touchList.item(i);
66
- x += touch.clientX;
67
- y += touch.clientY;
65
+
66
+ if (length > 0) {
67
+
68
+ for (let i = 0; i < length; i++) {
69
+ const touch = touchList.item(i);
70
+
71
+ if (touch === null) {
72
+ continue;
73
+ }
74
+
75
+ x += touch.clientX;
76
+ y += touch.clientY;
77
+ }
78
+
79
+ // average to get center
80
+ x /= length;
81
+ y /= length;
82
+
68
83
  }
69
- //
70
- result.set(x / length, y / length);
84
+
85
+ result.set(x, y);
86
+
71
87
  }
72
88
 
73
89
  /**
@@ -435,13 +451,13 @@ function PointerDevice(domElement) {
435
451
  observeTap(this.on.up, this.on.down, this.on.move, 10, this.on.tap);
436
452
  observeDrag(globalUp, this.on.down, this.on.move, this.on.dragStart, this.on.dragEnd, this.on.drag);
437
453
  observePinch({
438
- touchStart: touchStart,
439
- touchEnd: touchEnd,
440
- touchMove: touchMove,
441
- pinch: this.on.pinch,
442
- pinchStart: this.on.pinchStart,
443
- pinchEnd: this.on.pinchEnd
444
- });
454
+ touchStart: touchStart,
455
+ touchEnd: touchEnd,
456
+ touchMove: touchMove,
457
+ pinch: this.on.pinch,
458
+ pinchStart: this.on.pinchStart,
459
+ pinchEnd: this.on.pinchEnd
460
+ });
445
461
  }
446
462
 
447
463
  /**
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "productName": "Meep",
5
5
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
6
6
  "author": "Alexander Goldring",
7
- "version": "2.33.32",
7
+ "version": "2.33.33",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",