@loupekit/sdk 0.9.1 → 0.9.2-next.35
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/dist/index.global.js +25 -10
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2460,6 +2460,9 @@ var LoupeApp = class {
|
|
|
2460
2460
|
this.floatResize = null;
|
|
2461
2461
|
this.raf = 0;
|
|
2462
2462
|
// ---- inspector ------------------------------------------------------------
|
|
2463
|
+
// Pointer Events, not mouse events: a touch drag on a phone never fires
|
|
2464
|
+
// mousemove/mouseup, so Region/Record selection was impossible on touch devices.
|
|
2465
|
+
// Pointer events cover mouse, touch and pen with one handler each.
|
|
2463
2466
|
this.onMove = (e) => {
|
|
2464
2467
|
if (this.mode !== "inspect") return;
|
|
2465
2468
|
const target = this.pick(e.clientX, e.clientY);
|
|
@@ -2500,14 +2503,16 @@ var LoupeApp = class {
|
|
|
2500
2503
|
};
|
|
2501
2504
|
// ---- region ("free-size screenshot") selection ----------------------------
|
|
2502
2505
|
this.onRegionDown = (e) => {
|
|
2503
|
-
if (this.mode !== "region" && this.mode !== "record"
|
|
2506
|
+
if (this.mode !== "region" && this.mode !== "record") return;
|
|
2507
|
+
if (e.pointerType !== "touch" && e.pointerType !== "pen" && e.button !== 0) return;
|
|
2504
2508
|
const t = e.target;
|
|
2505
2509
|
if (t && (t.id === "loupe-root" || t.closest?.("#loupe-root"))) return;
|
|
2506
2510
|
e.preventDefault();
|
|
2507
2511
|
e.stopPropagation();
|
|
2508
2512
|
this.dragStart = { x: e.clientX, y: e.clientY };
|
|
2509
|
-
document.addEventListener("
|
|
2510
|
-
document.addEventListener("
|
|
2513
|
+
document.addEventListener("pointermove", this.onRegionMove, true);
|
|
2514
|
+
document.addEventListener("pointerup", this.onRegionUp, true);
|
|
2515
|
+
document.addEventListener("pointercancel", this.onRegionCancel, true);
|
|
2511
2516
|
this.drawSelection(e.clientX, e.clientY);
|
|
2512
2517
|
};
|
|
2513
2518
|
this.onRegionMove = (e) => {
|
|
@@ -2536,6 +2541,11 @@ var LoupeApp = class {
|
|
|
2536
2541
|
if (wasRecord) void this.finishRecording(vp);
|
|
2537
2542
|
else this.finishRegion(vp);
|
|
2538
2543
|
};
|
|
2544
|
+
/** The OS took over the gesture (e.g. a system swipe): drop the selection. */
|
|
2545
|
+
this.onRegionCancel = () => {
|
|
2546
|
+
this.cancelDrag();
|
|
2547
|
+
this.selbox.style.display = "none";
|
|
2548
|
+
};
|
|
2539
2549
|
// ---- free note (drop a comment anywhere, no element / no screenshot) -------
|
|
2540
2550
|
this.onFreeClick = (e) => {
|
|
2541
2551
|
if (this.mode !== "free") return;
|
|
@@ -2789,7 +2799,8 @@ var LoupeApp = class {
|
|
|
2789
2799
|
const recordBtn = this.toolBtn(RECORD_ICON, "Record", "record");
|
|
2790
2800
|
recordBtn.title = "Drag a box, record a screen video of it, and comment";
|
|
2791
2801
|
recordBtn.onclick = () => this.setMode(this.mode === "record" ? "off" : "record");
|
|
2792
|
-
|
|
2802
|
+
const canRecord = typeof navigator.mediaDevices?.getDisplayMedia === "function";
|
|
2803
|
+
tools.append(inspectBtn, freeBtn, regionBtn, ...canRecord ? [recordBtn] : []);
|
|
2793
2804
|
const listHead = el("div", "listhead");
|
|
2794
2805
|
listHead.append(document.createTextNode("Comments"));
|
|
2795
2806
|
this.countEl = el("span", "count", "0");
|
|
@@ -2910,8 +2921,9 @@ var LoupeApp = class {
|
|
|
2910
2921
|
}
|
|
2911
2922
|
cancelDrag() {
|
|
2912
2923
|
this.dragStart = null;
|
|
2913
|
-
document.removeEventListener("
|
|
2914
|
-
document.removeEventListener("
|
|
2924
|
+
document.removeEventListener("pointermove", this.onRegionMove, true);
|
|
2925
|
+
document.removeEventListener("pointerup", this.onRegionUp, true);
|
|
2926
|
+
document.removeEventListener("pointercancel", this.onRegionCancel, true);
|
|
2915
2927
|
}
|
|
2916
2928
|
/**
|
|
2917
2929
|
* Anchor a dragged viewport rect to the element under its center so it survives
|
|
@@ -3013,20 +3025,23 @@ var LoupeApp = class {
|
|
|
3013
3025
|
this.dock.querySelector('[data-role="region"]')?.classList.toggle("on", mode === "region");
|
|
3014
3026
|
this.dock.querySelector('[data-role="record"]')?.classList.toggle("on", mode === "record");
|
|
3015
3027
|
this.dock.classList.toggle("inspecting", mode !== "off");
|
|
3016
|
-
document.removeEventListener("
|
|
3028
|
+
document.removeEventListener("pointermove", this.onMove, true);
|
|
3029
|
+
document.removeEventListener("pointerdown", this.onMove, true);
|
|
3017
3030
|
document.removeEventListener("click", this.onClick, true);
|
|
3018
3031
|
document.removeEventListener("click", this.onFreeClick, true);
|
|
3019
|
-
document.removeEventListener("
|
|
3032
|
+
document.removeEventListener("pointerdown", this.onRegionDown, true);
|
|
3033
|
+
document.documentElement.style.touchAction = mode === "region" || mode === "record" ? "none" : "";
|
|
3020
3034
|
if (mode === "off") return;
|
|
3021
3035
|
document.addEventListener("keydown", this.onKey, true);
|
|
3022
3036
|
this.closeComposer();
|
|
3023
3037
|
if (mode === "inspect") {
|
|
3024
|
-
document.addEventListener("
|
|
3038
|
+
document.addEventListener("pointermove", this.onMove, true);
|
|
3039
|
+
document.addEventListener("pointerdown", this.onMove, true);
|
|
3025
3040
|
document.addEventListener("click", this.onClick, true);
|
|
3026
3041
|
} else if (mode === "free") {
|
|
3027
3042
|
document.addEventListener("click", this.onFreeClick, true);
|
|
3028
3043
|
} else if (mode === "region" || mode === "record") {
|
|
3029
|
-
document.addEventListener("
|
|
3044
|
+
document.addEventListener("pointerdown", this.onRegionDown, true);
|
|
3030
3045
|
}
|
|
3031
3046
|
}
|
|
3032
3047
|
// ---- composer -------------------------------------------------------------
|