@lemoncat7/dsh-theme-xiaohei 0.3.1 → 0.3.2
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 +7 -5
- package/lib/chrome/sidebar.d.ts +1 -1
- package/lib/chrome/sidebar.js +16 -0
- package/lib/client.js +410 -6
- package/lib/generated-character-motion.d.ts +4 -0
- package/lib/generated-character-motion.js +2 -0
- package/lib/metallic-brand-mark.js +16 -2
- package/lib/scene/character-motion-clock.d.ts +18 -0
- package/lib/scene/character-motion-clock.js +57 -0
- package/lib/scene/character-motion-types.d.ts +12 -0
- package/lib/scene/character-motion-types.js +2 -0
- package/lib/scene/character-motion.d.ts +6 -0
- package/lib/scene/character-motion.js +126 -0
- package/lib/scene/character-rig-renderer.d.ts +4 -0
- package/lib/scene/character-rig-renderer.js +85 -0
- package/lib/scene/character-rig.d.ts +20 -0
- package/lib/scene/character-rig.js +53 -0
- package/lib/scene/wallpaper-character-styles.js +10 -0
- package/lib/scene/wallpaper-character.d.ts +1 -1
- package/lib/scene/wallpaper-character.js +19 -1
- package/lib/sidebar-glass.js +13 -3
- package/lib/sidebar-reveal.d.ts +8 -0
- package/lib/sidebar-reveal.js +51 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Synchronize native wide content with the visible column, without changing
|
|
2
|
+
* Host layout/state or adding a competing animation timer. */
|
|
3
|
+
export function createSidebarReveal(doc) {
|
|
4
|
+
let shell;
|
|
5
|
+
let observer;
|
|
6
|
+
let phase = '', width = 0, waiting = false;
|
|
7
|
+
const attribute = 'data-xiaohei-sidebar-reveal';
|
|
8
|
+
const readPhase = () => shell?.className.includes('_collapsed') ? 'rail'
|
|
9
|
+
: shell?.className.includes('_fading') ? 'closing' : 'wide';
|
|
10
|
+
const apply = () => {
|
|
11
|
+
if (!shell)
|
|
12
|
+
return;
|
|
13
|
+
// The Host freezes its shell at the requested width during grid motion.
|
|
14
|
+
// Reading the inline target does not force a layout.
|
|
15
|
+
const target = Number.parseFloat(shell.style.width);
|
|
16
|
+
if (waiting && phase === 'wide' && (!Number.isFinite(target) || width >= target - 2))
|
|
17
|
+
waiting = false;
|
|
18
|
+
const value = waiting ? 'waiting' : 'ready';
|
|
19
|
+
if (shell.getAttribute(attribute) !== value)
|
|
20
|
+
shell.setAttribute(attribute, value);
|
|
21
|
+
};
|
|
22
|
+
const changed = () => {
|
|
23
|
+
const next = readPhase();
|
|
24
|
+
if (next === 'wide' && phase !== 'wide')
|
|
25
|
+
waiting = true;
|
|
26
|
+
if (next === 'rail')
|
|
27
|
+
waiting = false;
|
|
28
|
+
phase = next;
|
|
29
|
+
apply();
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
setColumn(column) {
|
|
33
|
+
const next = column?.querySelector?.("[data-slot='sidebar'] > div") ?? undefined;
|
|
34
|
+
if (next === shell)
|
|
35
|
+
return;
|
|
36
|
+
observer?.disconnect();
|
|
37
|
+
shell?.removeAttribute(attribute);
|
|
38
|
+
shell = next;
|
|
39
|
+
waiting = false;
|
|
40
|
+
phase = readPhase();
|
|
41
|
+
if (!shell)
|
|
42
|
+
return;
|
|
43
|
+
observer = new doc.defaultView.MutationObserver(changed);
|
|
44
|
+
observer.observe(shell, { attributes: true, attributeFilter: ['class', 'style'] });
|
|
45
|
+
apply();
|
|
46
|
+
},
|
|
47
|
+
resize(nextWidth) { width = nextWidth; apply(); },
|
|
48
|
+
dispose() { observer?.disconnect(); shell?.removeAttribute(attribute); shell = undefined; },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=sidebar-reveal.js.map
|