remarqueeble 0.1.0 → 0.3.0

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.
@@ -1,4 +1,4 @@
1
- /*! remarqueeble v0.1.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
1
+ /*! remarqueeble v0.3.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  //#region src/lib/remarqueeble.ts
4
4
  var DEFAULT_DIRECTION = "left";
@@ -24,6 +24,15 @@ var CSS_VAR_HEIGHT = "--attr-height";
24
24
  var CSS_VAR_HSPACE = "--attr-hspace";
25
25
  var CSS_VAR_VSPACE = "--attr-vspace";
26
26
  var CSS_VAR_BG_COLOR = "--attr-bgcolor";
27
+ var CSS_VAR_ANIMATION_DURATION = "--animation-duration";
28
+ var CSS_VAR_ANIMATION_DIRECTION = "--animation-direction";
29
+ var CSS_VAR_ANIMATION_ITERATION_COUNT = "--animation-iteration-count";
30
+ var CSS_VAR_ANIMATION_PLAY_STATE = "--animation-play-state";
31
+ var CSS_VAR_ANIMATION_TIMING_FUNCTION = "--animation-timing-function";
32
+ var CSS_VAR_TRANSLATE_X_END = "--translate-x-end";
33
+ var CSS_VAR_TRANSLATE_X_START = "--translate-x-start";
34
+ var CSS_VAR_TRANSLATE_Y_END = "--translate-y-end";
35
+ var CSS_VAR_TRANSLATE_Y_START = "--translate-y-start";
27
36
  var HTMLElementBase = globalThis.HTMLElement ?? class {};
28
37
  var parsePresentationalDimension = (value) => {
29
38
  if (value === null) return null;
@@ -84,11 +93,6 @@ var RemarqueebleElement = class extends HTMLElementBase {
84
93
  ];
85
94
  track;
86
95
  running = false;
87
- position = 0;
88
- lastTime = null;
89
- loopsDone = 0;
90
- forward = true;
91
- rafId = null;
92
96
  constructor() {
93
97
  super();
94
98
  const shadowRoot = this.attachShadow({ mode: "open" });
@@ -113,9 +117,32 @@ var RemarqueebleElement = class extends HTMLElementBase {
113
117
  }
114
118
 
115
119
  .track {
120
+ animation: remarqueeble-motion
121
+ var(${CSS_VAR_ANIMATION_DURATION}, 10s)
122
+ var(${CSS_VAR_ANIMATION_TIMING_FUNCTION}, linear)
123
+ var(${CSS_VAR_ANIMATION_ITERATION_COUNT}, infinite)
124
+ var(${CSS_VAR_ANIMATION_DIRECTION}, normal)
125
+ both;
126
+ animation-play-state: var(${CSS_VAR_ANIMATION_PLAY_STATE}, running);
116
127
  display: inline-block;
117
128
  will-change: transform;
118
129
  }
130
+
131
+ @keyframes remarqueeble-motion {
132
+ from {
133
+ transform: translate(
134
+ var(${CSS_VAR_TRANSLATE_X_START}, 100%),
135
+ var(${CSS_VAR_TRANSLATE_Y_START}, 0px)
136
+ );
137
+ }
138
+
139
+ to {
140
+ transform: translate(
141
+ var(${CSS_VAR_TRANSLATE_X_END}, -100%),
142
+ var(${CSS_VAR_TRANSLATE_Y_END}, 0px)
143
+ );
144
+ }
145
+ }
119
146
  </style>
120
147
 
121
148
  <span class="track"><slot></slot></span>
@@ -123,6 +150,7 @@ var RemarqueebleElement = class extends HTMLElementBase {
123
150
  const track = shadowRoot.querySelector(".track");
124
151
  if (!track) throw new Error("Remarqueeble track element was not created.");
125
152
  this.track = track;
153
+ this.track.addEventListener("animationend", () => this.handleAnimationEnd());
126
154
  }
127
155
  connectedCallback() {
128
156
  this.running = true;
@@ -130,16 +158,10 @@ var RemarqueebleElement = class extends HTMLElementBase {
130
158
  requestAnimationFrame(() => {
131
159
  if (!this.isConnected || !this.running) return;
132
160
  this.reset();
133
- this.tick();
134
161
  });
135
162
  }
136
163
  disconnectedCallback() {
137
164
  this.running = false;
138
- this.lastTime = null;
139
- if (this.rafId !== null) {
140
- cancelAnimationFrame(this.rafId);
141
- this.rafId = null;
142
- }
143
165
  }
144
166
  attributeChangedCallback(_name, oldValue, newValue) {
145
167
  if (oldValue === newValue) return;
@@ -177,18 +199,16 @@ var RemarqueebleElement = class extends HTMLElementBase {
177
199
  start() {
178
200
  if (this.running) return;
179
201
  this.running = true;
180
- this.lastTime = null;
181
- this.tick();
202
+ this.reset();
203
+ this.syncAnimationPlayState();
182
204
  }
183
205
  stop() {
184
206
  this.running = false;
185
- if (this.rafId !== null) {
186
- cancelAnimationFrame(this.rafId);
187
- this.rafId = null;
188
- }
207
+ this.syncAnimationPlayState();
189
208
  }
190
209
  syncPresentationalHints() {
191
210
  for (const hint of ATTRIBUTE_HINTS) this.syncVar(hint);
211
+ this.syncAnimationPlayState();
192
212
  }
193
213
  syncVar(hint) {
194
214
  const raw = this.getAttribute(hint.attribute);
@@ -204,10 +224,7 @@ var RemarqueebleElement = class extends HTMLElementBase {
204
224
  reset() {
205
225
  const hostSize = this.getHostSize();
206
226
  const trackSize = this.getTrackSize();
207
- this.loopsDone = 0;
208
- this.forward = true;
209
- this.position = this.behavior === "alternate" ? this.getAlternateStartPosition(hostSize, trackSize) : this.getStartPosition(hostSize, trackSize);
210
- this.render();
227
+ this.syncAnimation(hostSize, trackSize);
211
228
  }
212
229
  getHostSize() {
213
230
  return this.isVerticalDirection ? this.clientHeight : this.clientWidth;
@@ -230,69 +247,53 @@ var RemarqueebleElement = class extends HTMLElementBase {
230
247
  getAlternateStartPosition(hostSize, trackSize) {
231
248
  return this.directionSign < 0 ? hostSize - trackSize : 0;
232
249
  }
233
- tick(time = performance.now()) {
234
- if (!this.running) return;
235
- if (this.lastTime === null) this.lastTime = time;
236
- if (time - this.lastTime >= this.scrollDelay) {
237
- this.step();
238
- this.lastTime = time;
239
- }
240
- if (!this.running) return;
241
- this.rafId = requestAnimationFrame((nextTime) => this.tick(nextTime));
250
+ syncAnimationPlayState() {
251
+ this.style.setProperty(CSS_VAR_ANIMATION_PLAY_STATE, this.running ? "running" : "paused");
242
252
  }
243
- step() {
244
- const hostSize = this.getHostSize();
245
- const trackSize = this.getTrackSize();
246
- const startPosition = this.getStartPosition(hostSize, trackSize);
247
- const flushEndPosition = this.getFlushEndPosition(hostSize, trackSize);
248
- const offEndPosition = this.getOffEndPosition(hostSize, trackSize);
249
- const slideEndPosition = this.getSlideEndPosition(hostSize, trackSize);
250
- const alternateStartPosition = this.getAlternateStartPosition(hostSize, trackSize);
251
- const amount = this.scrollAmount;
252
- const delta = this.directionSign * amount;
253
- if (this.behavior === "alternate") {
254
- this.position += this.forward ? delta : -delta;
255
- if (this.forward) {
256
- if (this.directionSign < 0 && this.position <= flushEndPosition || this.directionSign > 0 && this.position >= flushEndPosition) {
257
- this.position = flushEndPosition;
258
- this.forward = false;
259
- this.incrementLoopCount();
260
- if (this.shouldStopAfterLoop()) this.stop();
261
- }
262
- } else if (this.directionSign < 0 && this.position >= alternateStartPosition || this.directionSign > 0 && this.position <= alternateStartPosition) {
263
- this.position = alternateStartPosition;
264
- this.forward = true;
265
- this.incrementLoopCount();
266
- if (this.shouldStopAfterLoop()) this.stop();
267
- }
268
- } else if (this.behavior === "slide") {
269
- this.position += delta;
270
- if (this.directionSign < 0 && this.position <= slideEndPosition || this.directionSign > 0 && this.position >= slideEndPosition) {
271
- this.position = slideEndPosition;
272
- this.incrementLoopCount();
273
- if (!this.hasAttribute(ATTR_LOOP) || this.loop <= 0) this.stop();
274
- else if (this.shouldStopAfterLoop()) this.stop();
275
- else this.position = startPosition;
276
- }
253
+ syncAnimation(hostSize, trackSize) {
254
+ const startPosition = this.behavior === "alternate" ? this.getAlternateStartPosition(hostSize, trackSize) : this.getStartPosition(hostSize, trackSize);
255
+ const endPosition = this.behavior === "slide" ? this.getSlideEndPosition(hostSize, trackSize) : this.behavior === "alternate" ? this.getFlushEndPosition(hostSize, trackSize) : this.getOffEndPosition(hostSize, trackSize);
256
+ const distance = Math.abs(endPosition - startPosition);
257
+ const steps = Math.max(1, Math.ceil(distance / Math.max(1, this.scrollAmount)));
258
+ const duration = Math.max(1, steps * this.scrollDelay);
259
+ const iterationCount = this.getCssIterationCount();
260
+ this.track.style.removeProperty("transform");
261
+ this.style.setProperty(CSS_VAR_ANIMATION_DURATION, `${duration}ms`);
262
+ this.style.setProperty(CSS_VAR_ANIMATION_DIRECTION, this.behavior === "alternate" ? "alternate" : "normal");
263
+ this.style.setProperty(CSS_VAR_ANIMATION_ITERATION_COUNT, iterationCount);
264
+ this.style.setProperty(CSS_VAR_ANIMATION_TIMING_FUNCTION, `steps(${steps}, end)`);
265
+ if (this.isVerticalDirection) {
266
+ this.style.setProperty(CSS_VAR_TRANSLATE_X_START, "0px");
267
+ this.style.setProperty(CSS_VAR_TRANSLATE_X_END, "0px");
268
+ this.style.setProperty(CSS_VAR_TRANSLATE_Y_START, `${startPosition}px`);
269
+ this.style.setProperty(CSS_VAR_TRANSLATE_Y_END, `${endPosition}px`);
277
270
  } else {
278
- this.position += delta;
279
- if (this.directionSign < 0 && this.position <= offEndPosition || this.directionSign > 0 && this.position >= offEndPosition) {
280
- this.position = startPosition;
281
- this.incrementLoopCount();
282
- if (this.shouldStopAfterLoop()) this.stop();
283
- }
271
+ this.style.setProperty(CSS_VAR_TRANSLATE_X_START, `${startPosition}px`);
272
+ this.style.setProperty(CSS_VAR_TRANSLATE_X_END, `${endPosition}px`);
273
+ this.style.setProperty(CSS_VAR_TRANSLATE_Y_START, "0px");
274
+ this.style.setProperty(CSS_VAR_TRANSLATE_Y_END, "0px");
284
275
  }
285
- this.render();
276
+ this.restartAnimation();
286
277
  }
287
- incrementLoopCount() {
288
- this.loopsDone++;
278
+ getCssIterationCount() {
279
+ if (this.behavior === "slide" && !this.hasAttribute(ATTR_LOOP)) return "1";
280
+ if (!this.hasAttribute(ATTR_LOOP)) return "infinite";
281
+ if (Number.isFinite(this.loop) && this.loop > 0) return String(this.loop);
282
+ return "infinite";
283
+ }
284
+ handleAnimationEnd() {
285
+ if (!this.hasFiniteAnimation()) return;
286
+ this.running = false;
287
+ this.syncAnimationPlayState();
289
288
  }
290
- shouldStopAfterLoop() {
291
- return this.hasAttribute(ATTR_LOOP) && this.loop > 0 && this.loopsDone >= this.loop;
289
+ restartAnimation() {
290
+ this.track.style.animationName = "none";
291
+ this.track.offsetWidth;
292
+ this.track.style.removeProperty("animation-name");
292
293
  }
293
- render() {
294
- if (this.isVerticalDirection) this.track.style.transform = `translateY(${this.position}px)`;
295
- else this.track.style.transform = `translateX(${this.position}px)`;
294
+ hasFiniteAnimation() {
295
+ if (this.behavior === "slide" && !this.hasAttribute(ATTR_LOOP)) return true;
296
+ return this.hasAttribute(ATTR_LOOP) && Number.isFinite(this.loop) && this.loop > 0;
296
297
  }
297
298
  };
298
299
  var defineRemarqueebleElements = () => {
@@ -8,11 +8,6 @@ export declare class RemarqueebleElement extends HTMLElementBase {
8
8
  static observedAttributes: string[];
9
9
  private readonly track;
10
10
  private running;
11
- private position;
12
- private lastTime;
13
- private loopsDone;
14
- private forward;
15
- private rafId;
16
11
  constructor();
17
12
  connectedCallback(): void;
18
13
  disconnectedCallback(): void;
@@ -36,11 +31,12 @@ export declare class RemarqueebleElement extends HTMLElementBase {
36
31
  private getOffEndPosition;
37
32
  private getSlideEndPosition;
38
33
  private getAlternateStartPosition;
39
- private tick;
40
- private step;
41
- private incrementLoopCount;
42
- private shouldStopAfterLoop;
43
- private render;
34
+ private syncAnimationPlayState;
35
+ private syncAnimation;
36
+ private getCssIterationCount;
37
+ private handleAnimationEnd;
38
+ private restartAnimation;
39
+ private hasFiniteAnimation;
44
40
  }
45
41
  export declare const defineRemarqueebleElements: () => void;
46
42
  declare global {
@@ -0,0 +1,52 @@
1
+ /*! remarqueeble v0.3.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
2
+ var remarqueeble=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=`left`,n=`scroll`,r=6,i=85,a=60,o=`200px`,s=`calc(100% - (var(--attr-hspace, 0px) * 2))`,c=`direction`,l=`behavior`,u=`scrollamount`,d=`scrolldelay`,f=`truespeed`,p=`loop`,m=`bgcolor`,h=`width`,g=`height`,_=`hspace`,v=`vspace`,y=`--attr-width`,b=`--attr-height`,x=`--attr-hspace`,S=`--attr-vspace`,C=`--attr-bgcolor`,w=`--animation-duration`,T=`--animation-direction`,E=`--animation-iteration-count`,D=`--animation-play-state`,O=`--animation-timing-function`,k=`--translate-x-end`,A=`--translate-x-start`,j=`--translate-y-end`,M=`--translate-y-start`,N=globalThis.HTMLElement??class{},P=e=>{if(e===null)return null;let t=e.trim();return t===``?null:/^[+-]?(?:\d+|\d*\.\d+)$/.test(t)?`${t}px`:globalThis.CSS?.supports(`width`,t)?t:null},F=e=>{if(e===null)return null;let t=e.trim();return t===``?null:globalThis.CSS?.supports(`background-color`,t)?t:null},I=[{attribute:h,cssVar:y,parser:P},{attribute:g,cssVar:b,parser:P,fallback(e){return e.isVerticalDirection&&!e.hasAttribute(g)?o:null}},{attribute:_,cssVar:x,parser:P},{attribute:v,cssVar:S,parser:P},{attribute:m,cssVar:C,parser:F}],L=class extends N{static observedAttributes=[c,l,u,d,f,p,m,h,g,_,v];track;running=!1;constructor(){super();let e=this.attachShadow({mode:`open`});e.innerHTML=`
3
+ <style>
4
+ :host {
5
+ display: inline-block;
6
+ text-align: initial;
7
+ overflow: hidden !important;
8
+ white-space: nowrap;
9
+ width: var(${y}, ${s});
10
+ height: var(${b}, auto);
11
+ margin-inline: var(${x}, 0px);
12
+ margin-block: var(${S}, 0px);
13
+ background-color: var(${C}, transparent);
14
+ box-sizing: border-box;
15
+ }
16
+
17
+ :host([direction="up"]),
18
+ :host([direction="down"]) {
19
+ white-space: normal;
20
+ }
21
+
22
+ .track {
23
+ animation: remarqueeble-motion
24
+ var(${w}, 10s)
25
+ var(${O}, linear)
26
+ var(${E}, infinite)
27
+ var(${T}, normal)
28
+ both;
29
+ animation-play-state: var(${D}, running);
30
+ display: inline-block;
31
+ will-change: transform;
32
+ }
33
+
34
+ @keyframes remarqueeble-motion {
35
+ from {
36
+ transform: translate(
37
+ var(${A}, 100%),
38
+ var(${M}, 0px)
39
+ );
40
+ }
41
+
42
+ to {
43
+ transform: translate(
44
+ var(${k}, -100%),
45
+ var(${j}, 0px)
46
+ );
47
+ }
48
+ }
49
+ </style>
50
+
51
+ <span class="track"><slot></slot></span>
52
+ `;let t=e.querySelector(`.track`);if(!t)throw Error(`Remarqueeble track element was not created.`);this.track=t,this.track.addEventListener(`animationend`,()=>this.handleAnimationEnd())}connectedCallback(){this.running=!0,this.syncPresentationalHints(),requestAnimationFrame(()=>{!this.isConnected||!this.running||this.reset()})}disconnectedCallback(){this.running=!1}attributeChangedCallback(e,t,n){t!==n&&(this.syncPresentationalHints(),this.isConnected&&this.reset())}get direction(){return this.getAttribute(c)||t}get behavior(){return this.getAttribute(l)||n}get scrollAmount(){let e=this.getAttribute(u),t=e===null||e.trim()===``?NaN:Number(e);return Number.isFinite(t)&&t>=0?t:r}get scrollDelay(){let e=this.getAttribute(d),t=e===null||e.trim()===``?NaN:Number(e),n=Number.isFinite(t)&&t>=0?t:i;return this.hasAttribute(f)?n:Math.max(n,a)}get loop(){let e=this.getAttribute(p);return e===null?-1:Number(e)}get directionSign(){return this.direction===`right`||this.direction===`down`?1:-1}get isVerticalDirection(){return this.direction===`up`||this.direction===`down`}start(){this.running||(this.running=!0,this.reset(),this.syncAnimationPlayState())}stop(){this.running=!1,this.syncAnimationPlayState()}syncPresentationalHints(){for(let e of I)this.syncVar(e);this.syncAnimationPlayState()}syncVar(e){let t=this.getAttribute(e.attribute),n=e.parser(t),r=e.fallback?e.fallback(this):null;if(n==null){r==null?this.style.removeProperty(e.cssVar):this.style.setProperty(e.cssVar,r);return}this.style.setProperty(e.cssVar,n)}reset(){let e=this.getHostSize(),t=this.getTrackSize();this.syncAnimation(e,t)}getHostSize(){return this.isVerticalDirection?this.clientHeight:this.clientWidth}getTrackSize(){return this.isVerticalDirection?this.track.offsetHeight:this.track.offsetWidth}getStartPosition(e,t){return this.directionSign<0?e:-t}getFlushEndPosition(e,t){return this.directionSign<0?0:e-t}getOffEndPosition(e,t){return this.directionSign<0?-t:e}getSlideEndPosition(e,t){return this.directionSign<0?0:e-t}getAlternateStartPosition(e,t){return this.directionSign<0?e-t:0}syncAnimationPlayState(){this.style.setProperty(D,this.running?`running`:`paused`)}syncAnimation(e,t){let n=this.behavior===`alternate`?this.getAlternateStartPosition(e,t):this.getStartPosition(e,t),r=this.behavior===`slide`?this.getSlideEndPosition(e,t):this.behavior===`alternate`?this.getFlushEndPosition(e,t):this.getOffEndPosition(e,t),i=Math.abs(r-n),a=Math.max(1,Math.ceil(i/Math.max(1,this.scrollAmount))),o=Math.max(1,a*this.scrollDelay),s=this.getCssIterationCount();this.track.style.removeProperty(`transform`),this.style.setProperty(w,`${o}ms`),this.style.setProperty(T,this.behavior===`alternate`?`alternate`:`normal`),this.style.setProperty(E,s),this.style.setProperty(O,`steps(${a}, end)`),this.isVerticalDirection?(this.style.setProperty(A,`0px`),this.style.setProperty(k,`0px`),this.style.setProperty(M,`${n}px`),this.style.setProperty(j,`${r}px`)):(this.style.setProperty(A,`${n}px`),this.style.setProperty(k,`${r}px`),this.style.setProperty(M,`0px`),this.style.setProperty(j,`0px`)),this.restartAnimation()}getCssIterationCount(){return this.behavior===`slide`&&!this.hasAttribute(p)?`1`:this.hasAttribute(p)&&Number.isFinite(this.loop)&&this.loop>0?String(this.loop):`infinite`}handleAnimationEnd(){this.hasFiniteAnimation()&&(this.running=!1,this.syncAnimationPlayState())}restartAnimation(){this.track.style.animationName=`none`,this.track.offsetWidth,this.track.style.removeProperty(`animation-name`)}hasFiniteAnimation(){return this.behavior===`slide`&&!this.hasAttribute(p)?!0:this.hasAttribute(p)&&Number.isFinite(this.loop)&&this.loop>0}};return e.RemarqueebleElement=L,e.defineRemarqueebleElements=()=>{typeof customElements>`u`||(customElements.get(`re-marquee`)||customElements.define(`re-marquee`,L),customElements.get(`re-marquee-ble`)||customElements.define(`re-marquee-ble`,L))},e.parseLegacyColor=F,e.parsePresentationalDimension=P,e})({});
@@ -0,0 +1,215 @@
1
+ /*! remarqueeble v0.3.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
2
+ //#region src/lib/remarqueeble.ts
3
+ var e = "direction", t = "behavior", n = "scrollamount", r = "scrolldelay", i = "truespeed", a = "loop", o = "bgcolor", s = "width", c = "height", l = "hspace", u = "vspace", d = "--attr-width", f = "--attr-height", p = "--attr-hspace", m = "--attr-vspace", h = "--attr-bgcolor", g = "--animation-duration", _ = "--animation-direction", v = "--animation-iteration-count", y = "--animation-play-state", b = "--animation-timing-function", x = "--translate-x-end", S = "--translate-x-start", C = "--translate-y-end", w = "--translate-y-start", T = globalThis.HTMLElement ?? class {}, E = (e) => {
4
+ if (e === null) return null;
5
+ let t = e.trim();
6
+ return t === "" ? null : /^[+-]?(?:\d+|\d*\.\d+)$/.test(t) ? `${t}px` : globalThis.CSS?.supports("width", t) ? t : null;
7
+ }, D = (e) => {
8
+ if (e === null) return null;
9
+ let t = e.trim();
10
+ return t === "" ? null : globalThis.CSS?.supports("background-color", t) ? t : null;
11
+ }, O = [
12
+ {
13
+ attribute: s,
14
+ cssVar: d,
15
+ parser: E
16
+ },
17
+ {
18
+ attribute: c,
19
+ cssVar: f,
20
+ parser: E,
21
+ fallback(e) {
22
+ return e.isVerticalDirection && !e.hasAttribute(c) ? "200px" : null;
23
+ }
24
+ },
25
+ {
26
+ attribute: l,
27
+ cssVar: p,
28
+ parser: E
29
+ },
30
+ {
31
+ attribute: u,
32
+ cssVar: m,
33
+ parser: E
34
+ },
35
+ {
36
+ attribute: o,
37
+ cssVar: h,
38
+ parser: D
39
+ }
40
+ ], k = class extends T {
41
+ static observedAttributes = [
42
+ e,
43
+ t,
44
+ n,
45
+ r,
46
+ i,
47
+ a,
48
+ o,
49
+ s,
50
+ c,
51
+ l,
52
+ u
53
+ ];
54
+ track;
55
+ running = !1;
56
+ constructor() {
57
+ super();
58
+ let e = this.attachShadow({ mode: "open" });
59
+ e.innerHTML = `
60
+ <style>
61
+ :host {
62
+ display: inline-block;
63
+ text-align: initial;
64
+ overflow: hidden !important;
65
+ white-space: nowrap;
66
+ width: var(${d}, calc(100% - (var(--attr-hspace, 0px) * 2)));
67
+ height: var(${f}, auto);
68
+ margin-inline: var(${p}, 0px);
69
+ margin-block: var(${m}, 0px);
70
+ background-color: var(${h}, transparent);
71
+ box-sizing: border-box;
72
+ }
73
+
74
+ :host([direction="up"]),
75
+ :host([direction="down"]) {
76
+ white-space: normal;
77
+ }
78
+
79
+ .track {
80
+ animation: remarqueeble-motion
81
+ var(${g}, 10s)
82
+ var(${b}, linear)
83
+ var(${v}, infinite)
84
+ var(${_}, normal)
85
+ both;
86
+ animation-play-state: var(${y}, running);
87
+ display: inline-block;
88
+ will-change: transform;
89
+ }
90
+
91
+ @keyframes remarqueeble-motion {
92
+ from {
93
+ transform: translate(
94
+ var(${S}, 100%),
95
+ var(${w}, 0px)
96
+ );
97
+ }
98
+
99
+ to {
100
+ transform: translate(
101
+ var(${x}, -100%),
102
+ var(${C}, 0px)
103
+ );
104
+ }
105
+ }
106
+ </style>
107
+
108
+ <span class="track"><slot></slot></span>
109
+ `;
110
+ let t = e.querySelector(".track");
111
+ if (!t) throw Error("Remarqueeble track element was not created.");
112
+ this.track = t, this.track.addEventListener("animationend", () => this.handleAnimationEnd());
113
+ }
114
+ connectedCallback() {
115
+ this.running = !0, this.syncPresentationalHints(), requestAnimationFrame(() => {
116
+ !this.isConnected || !this.running || this.reset();
117
+ });
118
+ }
119
+ disconnectedCallback() {
120
+ this.running = !1;
121
+ }
122
+ attributeChangedCallback(e, t, n) {
123
+ t !== n && (this.syncPresentationalHints(), this.isConnected && this.reset());
124
+ }
125
+ get direction() {
126
+ return this.getAttribute(e) || "left";
127
+ }
128
+ get behavior() {
129
+ return this.getAttribute(t) || "scroll";
130
+ }
131
+ get scrollAmount() {
132
+ let e = this.getAttribute(n), t = e === null || e.trim() === "" ? NaN : Number(e);
133
+ return Number.isFinite(t) && t >= 0 ? t : 6;
134
+ }
135
+ get scrollDelay() {
136
+ let e = this.getAttribute(r), t = e === null || e.trim() === "" ? NaN : Number(e), n = Number.isFinite(t) && t >= 0 ? t : 85;
137
+ return this.hasAttribute(i) ? n : Math.max(n, 60);
138
+ }
139
+ get loop() {
140
+ let e = this.getAttribute(a);
141
+ return e === null ? -1 : Number(e);
142
+ }
143
+ get directionSign() {
144
+ return this.direction === "right" || this.direction === "down" ? 1 : -1;
145
+ }
146
+ get isVerticalDirection() {
147
+ return this.direction === "up" || this.direction === "down";
148
+ }
149
+ start() {
150
+ this.running || (this.running = !0, this.reset(), this.syncAnimationPlayState());
151
+ }
152
+ stop() {
153
+ this.running = !1, this.syncAnimationPlayState();
154
+ }
155
+ syncPresentationalHints() {
156
+ for (let e of O) this.syncVar(e);
157
+ this.syncAnimationPlayState();
158
+ }
159
+ syncVar(e) {
160
+ let t = this.getAttribute(e.attribute), n = e.parser(t), r = e.fallback ? e.fallback(this) : null;
161
+ if (n == null) {
162
+ r == null ? this.style.removeProperty(e.cssVar) : this.style.setProperty(e.cssVar, r);
163
+ return;
164
+ }
165
+ this.style.setProperty(e.cssVar, n);
166
+ }
167
+ reset() {
168
+ let e = this.getHostSize(), t = this.getTrackSize();
169
+ this.syncAnimation(e, t);
170
+ }
171
+ getHostSize() {
172
+ return this.isVerticalDirection ? this.clientHeight : this.clientWidth;
173
+ }
174
+ getTrackSize() {
175
+ return this.isVerticalDirection ? this.track.offsetHeight : this.track.offsetWidth;
176
+ }
177
+ getStartPosition(e, t) {
178
+ return this.directionSign < 0 ? e : -t;
179
+ }
180
+ getFlushEndPosition(e, t) {
181
+ return this.directionSign < 0 ? 0 : e - t;
182
+ }
183
+ getOffEndPosition(e, t) {
184
+ return this.directionSign < 0 ? -t : e;
185
+ }
186
+ getSlideEndPosition(e, t) {
187
+ return this.directionSign < 0 ? 0 : e - t;
188
+ }
189
+ getAlternateStartPosition(e, t) {
190
+ return this.directionSign < 0 ? e - t : 0;
191
+ }
192
+ syncAnimationPlayState() {
193
+ this.style.setProperty(y, this.running ? "running" : "paused");
194
+ }
195
+ syncAnimation(e, t) {
196
+ let n = this.behavior === "alternate" ? this.getAlternateStartPosition(e, t) : this.getStartPosition(e, t), r = this.behavior === "slide" ? this.getSlideEndPosition(e, t) : this.behavior === "alternate" ? this.getFlushEndPosition(e, t) : this.getOffEndPosition(e, t), i = Math.abs(r - n), a = Math.max(1, Math.ceil(i / Math.max(1, this.scrollAmount))), o = Math.max(1, a * this.scrollDelay), s = this.getCssIterationCount();
197
+ this.track.style.removeProperty("transform"), this.style.setProperty(g, `${o}ms`), this.style.setProperty(_, this.behavior === "alternate" ? "alternate" : "normal"), this.style.setProperty(v, s), this.style.setProperty(b, `steps(${a}, end)`), this.isVerticalDirection ? (this.style.setProperty(S, "0px"), this.style.setProperty(x, "0px"), this.style.setProperty(w, `${n}px`), this.style.setProperty(C, `${r}px`)) : (this.style.setProperty(S, `${n}px`), this.style.setProperty(x, `${r}px`), this.style.setProperty(w, "0px"), this.style.setProperty(C, "0px")), this.restartAnimation();
198
+ }
199
+ getCssIterationCount() {
200
+ return this.behavior === "slide" && !this.hasAttribute(a) ? "1" : this.hasAttribute(a) && Number.isFinite(this.loop) && this.loop > 0 ? String(this.loop) : "infinite";
201
+ }
202
+ handleAnimationEnd() {
203
+ this.hasFiniteAnimation() && (this.running = !1, this.syncAnimationPlayState());
204
+ }
205
+ restartAnimation() {
206
+ this.track.style.animationName = "none", this.track.offsetWidth, this.track.style.removeProperty("animation-name");
207
+ }
208
+ hasFiniteAnimation() {
209
+ return this.behavior === "slide" && !this.hasAttribute(a) ? !0 : this.hasAttribute(a) && Number.isFinite(this.loop) && this.loop > 0;
210
+ }
211
+ }, A = () => {
212
+ typeof customElements > "u" || (customElements.get("re-marquee") || customElements.define("re-marquee", k), customElements.get("re-marquee-ble") || customElements.define("re-marquee-ble", k));
213
+ };
214
+ //#endregion
215
+ export { k as RemarqueebleElement, A as defineRemarqueebleElements, D as parseLegacyColor, E as parsePresentationalDimension };