@glissade/element 0.11.0-pre.0 → 0.11.0-pre.1

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -10
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -55,11 +55,30 @@ var GsPlayerElement = class extends HTMLElement {
55
55
  attributeChangedCallback(name) {
56
56
  if (name === "controls") {
57
57
  this.#syncControls();
58
- if (this.isConnected && this.#scene) this.#remount();
58
+ this.#syncControlsSubscription();
59
59
  return;
60
60
  }
61
61
  if (this.isConnected && this.#scene) this.#remount();
62
62
  }
63
+ /** Wire the scrubber/time playhead subscription when controls exist, unwire
64
+ * when they don't — against the existing playhead, so toggling controls never
65
+ * disturbs playback position. */
66
+ #syncControlsSubscription() {
67
+ if (this.#controls && !this.#unsubscribe && this.#playhead) {
68
+ this.#unsubscribe = this.#playhead.subscribe(() => {
69
+ requestAnimationFrame(() => {
70
+ if (!this.#controls) return;
71
+ this.#syncReadout();
72
+ this.#syncButton();
73
+ });
74
+ });
75
+ this.#syncReadout();
76
+ this.#syncButton();
77
+ } else if (!this.#controls && this.#unsubscribe) {
78
+ this.#unsubscribe();
79
+ this.#unsubscribe = null;
80
+ }
81
+ }
63
82
  /** Build the controls subtree + listeners on demand; tear them down when gone. */
64
83
  #syncControls() {
65
84
  const want = this.hasAttribute("controls");
@@ -142,15 +161,7 @@ var GsPlayerElement = class extends HTMLElement {
142
161
  autoplay: this.hasAttribute("autoplay")
143
162
  });
144
163
  this.#playhead = scene.playhead;
145
- if (this.#controls) this.#unsubscribe = scene.playhead.subscribe(() => {
146
- requestAnimationFrame(() => {
147
- if (!this.#controls) return;
148
- this.#syncReadout();
149
- this.#syncButton();
150
- });
151
- });
152
- this.#syncReadout();
153
- this.#syncButton();
164
+ this.#syncControlsSubscription();
154
165
  }
155
166
  #syncReadout() {
156
167
  const c = this.#controls;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/element",
3
- "version": "0.11.0-pre.0",
3
+ "version": "0.11.0-pre.1",
4
4
  "description": "glissade <gs-player> custom element: zero-framework embedding with minimal, CSS-part themable controls.",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -18,10 +18,10 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@glissade/backend-canvas2d": "0.11.0-pre.0",
22
- "@glissade/core": "0.11.0-pre.0",
23
- "@glissade/player": "0.11.0-pre.0",
24
- "@glissade/scene": "0.11.0-pre.0"
21
+ "@glissade/backend-canvas2d": "0.11.0-pre.1",
22
+ "@glissade/core": "0.11.0-pre.1",
23
+ "@glissade/player": "0.11.0-pre.1",
24
+ "@glissade/scene": "0.11.0-pre.1"
25
25
  },
26
26
  "repository": {
27
27
  "type": "git",