@intentius/behold 0.29.42 → 0.29.43

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/web/embed.js CHANGED
@@ -99,3 +99,19 @@ export function quietCardLines(svg) {
99
99
  t.setAttribute("data-kiosk-quiet", "1");
100
100
  }
101
101
  }
102
+
103
+ /**
104
+ * Whether a plain wheel (no ctrl or meta key) zooms the graph: in the kiosk's
105
+ * bare frame it does, since the graph is the whole stage and there is nothing
106
+ * of the frame to scroll. A sideways-only scroll is left to the page.
107
+ */
108
+ export function wheelZoomsBare(bare, e) {
109
+ return !!bare && !!e && Math.abs(Number(e.deltaY) || 0) > 0;
110
+ }
111
+
112
+ /** A wheel event's vertical delta in px, whatever its unit: a line is 16 px, a page 800. */
113
+ export function wheelPx(e) {
114
+ const d = Number(e && e.deltaY) || 0;
115
+ const mode = e && e.deltaMode;
116
+ return mode === 1 ? d * 16 : mode === 2 ? d * 800 : d;
117
+ }
package/web/embed.test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { kioskQuietLine, readEmbed, selectMessage, viewFromMessage, THEME_ALIASES } from "./embed.js";
2
+ import { kioskQuietLine, readEmbed, selectMessage, viewFromMessage, THEME_ALIASES, wheelPx, wheelZoomsBare } from "./embed.js";
3
3
 
4
4
  describe("readEmbed (#476)", () => {
5
5
  it("reads embed, an exact host origin and a theme", () => {
@@ -72,3 +72,21 @@ describe("kioskQuietLine (behold#571)", () => {
72
72
  for (const t of ["network", "terraform_data.http_proxy_port", "waiting", "reads network · planned · 1 unknown", "wave 2 · planned", "", null]) expect(kioskQuietLine(t)).toBe(false);
73
73
  });
74
74
  });
75
+
76
+ describe("the wheel in the kiosk's bare frame", () => {
77
+ it("zooms on a plain mouse wheel there, and only there", () => {
78
+ expect(wheelZoomsBare(true, { deltaY: 100 })).toBe(true);
79
+ expect(wheelZoomsBare(true, { deltaY: -3 })).toBe(true);
80
+ expect(wheelZoomsBare(false, { deltaY: 100 })).toBe(false);
81
+ });
82
+ it("leaves a sideways-only scroll to the page", () => {
83
+ expect(wheelZoomsBare(true, { deltaX: 40, deltaY: 0 })).toBe(false);
84
+ expect(wheelZoomsBare(true, null)).toBe(false);
85
+ });
86
+ it("reads the delta in px whatever its unit", () => {
87
+ expect(wheelPx({ deltaY: 100, deltaMode: 0 })).toBe(100);
88
+ expect(wheelPx({ deltaY: 3, deltaMode: 1 })).toBe(48);
89
+ expect(wheelPx({ deltaY: 1, deltaMode: 2 })).toBe(800);
90
+ expect(wheelPx({})).toBe(0);
91
+ });
92
+ });