@blorkfield/overlay-core 0.11.2 → 0.11.3
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.
- package/README.md +5 -3
- package/dist/index.cjs +48 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -609,6 +609,14 @@ declare class OverlayScene {
|
|
|
609
609
|
private handleMouseUp;
|
|
610
610
|
/** Handle canvas clicks for click-to-fall behavior */
|
|
611
611
|
private handleCanvasClick;
|
|
612
|
+
/** Shared tap logic for mouse click and touch tap */
|
|
613
|
+
private handleTap;
|
|
614
|
+
/** Handle touch start — single finger grabs, multi-finger passes through for scroll/zoom */
|
|
615
|
+
private handleTouchStart;
|
|
616
|
+
/** Handle touch move — only tracks if something is grabbed */
|
|
617
|
+
private handleTouchMove;
|
|
618
|
+
/** Handle touch end/cancel — release grab; if it was a tap (no grab), trigger click-to-fall */
|
|
619
|
+
private handleTouchEnd;
|
|
612
620
|
/**
|
|
613
621
|
* Handler for Matter.js beforeRender event.
|
|
614
622
|
* Draws base background layers (color + image) before physics objects.
|
package/dist/index.d.ts
CHANGED
|
@@ -609,6 +609,14 @@ declare class OverlayScene {
|
|
|
609
609
|
private handleMouseUp;
|
|
610
610
|
/** Handle canvas clicks for click-to-fall behavior */
|
|
611
611
|
private handleCanvasClick;
|
|
612
|
+
/** Shared tap logic for mouse click and touch tap */
|
|
613
|
+
private handleTap;
|
|
614
|
+
/** Handle touch start — single finger grabs, multi-finger passes through for scroll/zoom */
|
|
615
|
+
private handleTouchStart;
|
|
616
|
+
/** Handle touch move — only tracks if something is grabbed */
|
|
617
|
+
private handleTouchMove;
|
|
618
|
+
/** Handle touch end/cancel — release grab; if it was a tap (no grab), trigger click-to-fall */
|
|
619
|
+
private handleTouchEnd;
|
|
612
620
|
/**
|
|
613
621
|
* Handler for Matter.js beforeRender event.
|
|
614
622
|
* Draws base background layers (color + image) before physics objects.
|
package/dist/index.js
CHANGED
|
@@ -1470,6 +1470,10 @@ var OverlayScene = class {
|
|
|
1470
1470
|
const rect = this.canvas.getBoundingClientRect();
|
|
1471
1471
|
const x = event.clientX - rect.left;
|
|
1472
1472
|
const y = event.clientY - rect.top;
|
|
1473
|
+
this.handleTap(x, y);
|
|
1474
|
+
};
|
|
1475
|
+
/** Shared tap logic for mouse click and touch tap */
|
|
1476
|
+
this.handleTap = (x, y) => {
|
|
1473
1477
|
const bodies = Matter5.Query.point(
|
|
1474
1478
|
Matter5.Composite.allBodies(this.engine.world),
|
|
1475
1479
|
{ x, y }
|
|
@@ -1487,6 +1491,42 @@ var OverlayScene = class {
|
|
|
1487
1491
|
}
|
|
1488
1492
|
}
|
|
1489
1493
|
};
|
|
1494
|
+
/** Handle touch start — single finger grabs, multi-finger passes through for scroll/zoom */
|
|
1495
|
+
this.handleTouchStart = (event) => {
|
|
1496
|
+
if (event.touches.length >= 2) return;
|
|
1497
|
+
const touch = event.touches[0];
|
|
1498
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
1499
|
+
const x = touch.clientX - rect.left;
|
|
1500
|
+
const y = touch.clientY - rect.top;
|
|
1501
|
+
this.followTargets.set("mouse", { x, y });
|
|
1502
|
+
const grabbed = this.startGrab();
|
|
1503
|
+
if (grabbed) event.preventDefault();
|
|
1504
|
+
};
|
|
1505
|
+
/** Handle touch move — only tracks if something is grabbed */
|
|
1506
|
+
this.handleTouchMove = (event) => {
|
|
1507
|
+
if (event.touches.length >= 2) return;
|
|
1508
|
+
if (!this.grabbedObjectId) return;
|
|
1509
|
+
event.preventDefault();
|
|
1510
|
+
const touch = event.touches[0];
|
|
1511
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
1512
|
+
const x = touch.clientX - rect.left;
|
|
1513
|
+
const y = touch.clientY - rect.top;
|
|
1514
|
+
this.followTargets.set("mouse", { x, y });
|
|
1515
|
+
};
|
|
1516
|
+
/** Handle touch end/cancel — release grab; if it was a tap (no grab), trigger click-to-fall */
|
|
1517
|
+
this.handleTouchEnd = (event) => {
|
|
1518
|
+
const wasGrabbed = this.grabbedObjectId !== null;
|
|
1519
|
+
this.endGrab();
|
|
1520
|
+
if (wasGrabbed) {
|
|
1521
|
+
event.preventDefault();
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
if (event.changedTouches.length > 0) {
|
|
1525
|
+
const touch = event.changedTouches[0];
|
|
1526
|
+
const rect = this.canvas.getBoundingClientRect();
|
|
1527
|
+
this.handleTap(touch.clientX - rect.left, touch.clientY - rect.top);
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1490
1530
|
/**
|
|
1491
1531
|
* Handler for Matter.js beforeRender event.
|
|
1492
1532
|
* Draws base background layers (color + image) before physics objects.
|
|
@@ -1639,6 +1679,10 @@ var OverlayScene = class {
|
|
|
1639
1679
|
canvas.addEventListener("mousemove", this.handleMouseMove);
|
|
1640
1680
|
canvas.addEventListener("mouseup", this.handleMouseUp);
|
|
1641
1681
|
canvas.addEventListener("click", this.handleCanvasClick);
|
|
1682
|
+
canvas.addEventListener("touchstart", this.handleTouchStart, { passive: false });
|
|
1683
|
+
canvas.addEventListener("touchmove", this.handleTouchMove, { passive: false });
|
|
1684
|
+
canvas.addEventListener("touchend", this.handleTouchEnd, { passive: false });
|
|
1685
|
+
canvas.addEventListener("touchcancel", this.handleTouchEnd, { passive: false });
|
|
1642
1686
|
this.effectManager = new EffectManager(
|
|
1643
1687
|
this.config.bounds,
|
|
1644
1688
|
(cfg) => this.spawnObjectAsync(cfg),
|
|
@@ -2063,6 +2107,10 @@ var OverlayScene = class {
|
|
|
2063
2107
|
this.canvas.removeEventListener("mousemove", this.handleMouseMove);
|
|
2064
2108
|
this.canvas.removeEventListener("mouseup", this.handleMouseUp);
|
|
2065
2109
|
this.canvas.removeEventListener("click", this.handleCanvasClick);
|
|
2110
|
+
this.canvas.removeEventListener("touchstart", this.handleTouchStart);
|
|
2111
|
+
this.canvas.removeEventListener("touchmove", this.handleTouchMove);
|
|
2112
|
+
this.canvas.removeEventListener("touchend", this.handleTouchEnd);
|
|
2113
|
+
this.canvas.removeEventListener("touchcancel", this.handleTouchEnd);
|
|
2066
2114
|
Matter5.Events.off(this.render, "beforeRender", this.handleBeforeRender);
|
|
2067
2115
|
Matter5.Events.off(this.render, "afterRender", this.handleAfterRender);
|
|
2068
2116
|
Matter5.Events.off(this.engine, "collisionStart", this.handleCollisionStart);
|