@unisim/sdk 0.180.7 → 0.180.8
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.
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
* - On leaving mid-glide, resumes from the frame actually on screen rather
|
|
23
23
|
* than snapping to wherever the free-running clock had reached. That is what
|
|
24
24
|
* `unSmoothstep` is for.
|
|
25
|
+
* - **While the window is not focused, finishes the loop it is in, rests on
|
|
26
|
+
* frame 0 and stops asking for frames** until focus returns (James,
|
|
27
|
+
* 2026-10-08). Every frame of this clock writes `--t`, which restyles the
|
|
28
|
+
* whole scene: measured on Universal PDF's welcome screen, this loop alone
|
|
29
|
+
* kept a style recalc and a layout running ~60 times a second, focused or
|
|
30
|
+
* not, for as long as the window was on screen. Frame 0 IS the end of a
|
|
31
|
+
* loop (0 → 1 → 0), so the rest is seamless and so is the restart.
|
|
25
32
|
*
|
|
26
33
|
* ── Three details that are load-bearing, not polish ────────────────────────
|
|
27
34
|
* ⚠️ **Reduced motion gets the FINISHED frame, not frame 0 and not a slower
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"illustrationClock.d.ts","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"illustrationClock.d.ts","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACtE,GAAG,EAAE;IAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,EAC1B,EAAE,OAAc,EAAE,QAAc,EAAE,GAAE,wBAA6B,GAChE,IAAI,CA6GN;AAED,+EAA+E;AAC/E,eAAO,MAAM,UAAU,GAAI,GAAG,MAAM,WAAwB,CAAA;AAE5D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,WAGrC,CAAA"}
|
|
@@ -23,6 +23,8 @@ export function useIllustrationClock(ref, { sweepMs = 5200, returnMs = 480 } = {
|
|
|
23
23
|
let hovering = false;
|
|
24
24
|
let from = 0; // where the glide back to frame 0 started
|
|
25
25
|
let since = 0; // ms into that glide
|
|
26
|
+
// The window is not focused: finish this loop, then rest. See the header.
|
|
27
|
+
let resting = !document.hasFocus();
|
|
26
28
|
function frame(now) {
|
|
27
29
|
const dt = Math.min(now - last, 100);
|
|
28
30
|
last = now;
|
|
@@ -37,7 +39,16 @@ export function useIllustrationClock(ref, { sweepMs = 5200, returnMs = 480 } = {
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
else {
|
|
40
|
-
|
|
42
|
+
const next = clock + dt / sweep.current;
|
|
43
|
+
if (resting && next >= 2) {
|
|
44
|
+
// End of the loop while unfocused — rest on frame 0.
|
|
45
|
+
clock = 0;
|
|
46
|
+
shown = 0;
|
|
47
|
+
set(0);
|
|
48
|
+
raf = 0;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
clock = next % 2;
|
|
41
52
|
shown = smoothstep(clock <= 1 ? clock : 2 - clock);
|
|
42
53
|
set(shown);
|
|
43
54
|
}
|
|
@@ -65,11 +76,22 @@ export function useIllustrationClock(ref, { sweepMs = 5200, returnMs = 480 } = {
|
|
|
65
76
|
clock = unSmoothstep(shown);
|
|
66
77
|
start();
|
|
67
78
|
}
|
|
79
|
+
function onBlur() {
|
|
80
|
+
resting = true;
|
|
81
|
+
}
|
|
82
|
+
function onFocus() {
|
|
83
|
+
if (!resting)
|
|
84
|
+
return;
|
|
85
|
+
resting = false;
|
|
86
|
+
start();
|
|
87
|
+
}
|
|
68
88
|
const canHover = window.matchMedia('(hover: hover)').matches;
|
|
69
89
|
if (canHover) {
|
|
70
90
|
el.addEventListener('pointerenter', onEnter);
|
|
71
91
|
el.addEventListener('pointerleave', onLeave);
|
|
72
92
|
}
|
|
93
|
+
window.addEventListener('blur', onBlur);
|
|
94
|
+
window.addEventListener('focus', onFocus);
|
|
73
95
|
start();
|
|
74
96
|
return () => {
|
|
75
97
|
if (raf)
|
|
@@ -78,6 +100,8 @@ export function useIllustrationClock(ref, { sweepMs = 5200, returnMs = 480 } = {
|
|
|
78
100
|
el.removeEventListener('pointerenter', onEnter);
|
|
79
101
|
el.removeEventListener('pointerleave', onLeave);
|
|
80
102
|
}
|
|
103
|
+
window.removeEventListener('blur', onBlur);
|
|
104
|
+
window.removeEventListener('focus', onFocus);
|
|
81
105
|
};
|
|
82
106
|
}, [ref]);
|
|
83
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"illustrationClock.js","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"illustrationClock.js","sourceRoot":"","sources":["../src/illustrationClock.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAwEzC,MAAM,UAAU,oBAAoB,CAClC,GAA0B,EAC1B,EAAE,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,GAAG,KAA+B,EAAE;IAEjE,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;IACvB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAA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