remarqueeble 0.1.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.
- package/LICENSE.md +15 -0
- package/README.md +129 -0
- package/dist/auto.d.ts +1 -0
- package/dist/remarqueeble-auto.cjs +307 -0
- package/dist/remarqueeble-auto.mjs +306 -0
- package/dist/remarqueeble.cjs +307 -0
- package/dist/remarqueeble.d.ts +52 -0
- package/dist/remarqueeble.mjs +303 -0
- package/dist/remarqueeble.umd.js +29 -0
- package/package.json +81 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/*! remarqueeble v0.1.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
|
|
2
|
+
//#region src/lib/remarqueeble.ts
|
|
3
|
+
var DEFAULT_DIRECTION = "left";
|
|
4
|
+
var DEFAULT_BEHAVIOR = "scroll";
|
|
5
|
+
var DEFAULT_SCROLL_AMOUNT = 6;
|
|
6
|
+
var DEFAULT_SCROLL_DELAY = 85;
|
|
7
|
+
var MIN_SCROLL_DELAY = 60;
|
|
8
|
+
var DEFAULT_VERTICAL_HEIGHT = "200px";
|
|
9
|
+
var DEFAULT_HOST_WIDTH = "calc(100% - (var(--attr-hspace, 0px) * 2))";
|
|
10
|
+
var ATTR_DIRECTION = "direction";
|
|
11
|
+
var ATTR_BEHAVIOR = "behavior";
|
|
12
|
+
var ATTR_SCROLL_AMOUNT = "scrollamount";
|
|
13
|
+
var ATTR_SCROLL_DELAY = "scrolldelay";
|
|
14
|
+
var ATTR_TRUE_SPEED = "truespeed";
|
|
15
|
+
var ATTR_LOOP = "loop";
|
|
16
|
+
var ATTR_BG_COLOR = "bgcolor";
|
|
17
|
+
var ATTR_WIDTH = "width";
|
|
18
|
+
var ATTR_HEIGHT = "height";
|
|
19
|
+
var ATTR_HSPACE = "hspace";
|
|
20
|
+
var ATTR_VSPACE = "vspace";
|
|
21
|
+
var CSS_VAR_WIDTH = "--attr-width";
|
|
22
|
+
var CSS_VAR_HEIGHT = "--attr-height";
|
|
23
|
+
var CSS_VAR_HSPACE = "--attr-hspace";
|
|
24
|
+
var CSS_VAR_VSPACE = "--attr-vspace";
|
|
25
|
+
var CSS_VAR_BG_COLOR = "--attr-bgcolor";
|
|
26
|
+
var HTMLElementBase = globalThis.HTMLElement ?? class {};
|
|
27
|
+
var parsePresentationalDimension = (value) => {
|
|
28
|
+
if (value === null) return null;
|
|
29
|
+
const trimmed = value.trim();
|
|
30
|
+
if (trimmed === "") return null;
|
|
31
|
+
if (/^[+-]?(?:\d+|\d*\.\d+)$/.test(trimmed)) return `${trimmed}px`;
|
|
32
|
+
return globalThis.CSS?.supports("width", trimmed) ? trimmed : null;
|
|
33
|
+
};
|
|
34
|
+
var parseLegacyColor = (value) => {
|
|
35
|
+
if (value === null) return null;
|
|
36
|
+
const trimmed = value.trim();
|
|
37
|
+
if (trimmed === "") return null;
|
|
38
|
+
return globalThis.CSS?.supports("background-color", trimmed) ? trimmed : null;
|
|
39
|
+
};
|
|
40
|
+
var ATTRIBUTE_HINTS = [
|
|
41
|
+
{
|
|
42
|
+
attribute: ATTR_WIDTH,
|
|
43
|
+
cssVar: CSS_VAR_WIDTH,
|
|
44
|
+
parser: parsePresentationalDimension
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
attribute: ATTR_HEIGHT,
|
|
48
|
+
cssVar: CSS_VAR_HEIGHT,
|
|
49
|
+
parser: parsePresentationalDimension,
|
|
50
|
+
fallback(element) {
|
|
51
|
+
return element.isVerticalDirection && !element.hasAttribute(ATTR_HEIGHT) ? DEFAULT_VERTICAL_HEIGHT : null;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
attribute: ATTR_HSPACE,
|
|
56
|
+
cssVar: CSS_VAR_HSPACE,
|
|
57
|
+
parser: parsePresentationalDimension
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
attribute: ATTR_VSPACE,
|
|
61
|
+
cssVar: CSS_VAR_VSPACE,
|
|
62
|
+
parser: parsePresentationalDimension
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
attribute: ATTR_BG_COLOR,
|
|
66
|
+
cssVar: CSS_VAR_BG_COLOR,
|
|
67
|
+
parser: parseLegacyColor
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
var RemarqueebleElement = class extends HTMLElementBase {
|
|
71
|
+
static observedAttributes = [
|
|
72
|
+
ATTR_DIRECTION,
|
|
73
|
+
ATTR_BEHAVIOR,
|
|
74
|
+
ATTR_SCROLL_AMOUNT,
|
|
75
|
+
ATTR_SCROLL_DELAY,
|
|
76
|
+
ATTR_TRUE_SPEED,
|
|
77
|
+
ATTR_LOOP,
|
|
78
|
+
ATTR_BG_COLOR,
|
|
79
|
+
ATTR_WIDTH,
|
|
80
|
+
ATTR_HEIGHT,
|
|
81
|
+
ATTR_HSPACE,
|
|
82
|
+
ATTR_VSPACE
|
|
83
|
+
];
|
|
84
|
+
track;
|
|
85
|
+
running = false;
|
|
86
|
+
position = 0;
|
|
87
|
+
lastTime = null;
|
|
88
|
+
loopsDone = 0;
|
|
89
|
+
forward = true;
|
|
90
|
+
rafId = null;
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
const shadowRoot = this.attachShadow({ mode: "open" });
|
|
94
|
+
shadowRoot.innerHTML = `
|
|
95
|
+
<style>
|
|
96
|
+
:host {
|
|
97
|
+
display: inline-block;
|
|
98
|
+
text-align: initial;
|
|
99
|
+
overflow: hidden !important;
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
width: var(${CSS_VAR_WIDTH}, ${DEFAULT_HOST_WIDTH});
|
|
102
|
+
height: var(${CSS_VAR_HEIGHT}, auto);
|
|
103
|
+
margin-inline: var(${CSS_VAR_HSPACE}, 0px);
|
|
104
|
+
margin-block: var(${CSS_VAR_VSPACE}, 0px);
|
|
105
|
+
background-color: var(${CSS_VAR_BG_COLOR}, transparent);
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
:host([direction="up"]),
|
|
110
|
+
:host([direction="down"]) {
|
|
111
|
+
white-space: normal;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.track {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
will-change: transform;
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
119
|
+
|
|
120
|
+
<span class="track"><slot></slot></span>
|
|
121
|
+
`;
|
|
122
|
+
const track = shadowRoot.querySelector(".track");
|
|
123
|
+
if (!track) throw new Error("Remarqueeble track element was not created.");
|
|
124
|
+
this.track = track;
|
|
125
|
+
}
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
this.running = true;
|
|
128
|
+
this.syncPresentationalHints();
|
|
129
|
+
requestAnimationFrame(() => {
|
|
130
|
+
if (!this.isConnected || !this.running) return;
|
|
131
|
+
this.reset();
|
|
132
|
+
this.tick();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
disconnectedCallback() {
|
|
136
|
+
this.running = false;
|
|
137
|
+
this.lastTime = null;
|
|
138
|
+
if (this.rafId !== null) {
|
|
139
|
+
cancelAnimationFrame(this.rafId);
|
|
140
|
+
this.rafId = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
attributeChangedCallback(_name, oldValue, newValue) {
|
|
144
|
+
if (oldValue === newValue) return;
|
|
145
|
+
this.syncPresentationalHints();
|
|
146
|
+
if (this.isConnected) this.reset();
|
|
147
|
+
}
|
|
148
|
+
get direction() {
|
|
149
|
+
return this.getAttribute(ATTR_DIRECTION) || DEFAULT_DIRECTION;
|
|
150
|
+
}
|
|
151
|
+
get behavior() {
|
|
152
|
+
return this.getAttribute(ATTR_BEHAVIOR) || DEFAULT_BEHAVIOR;
|
|
153
|
+
}
|
|
154
|
+
get scrollAmount() {
|
|
155
|
+
const raw = this.getAttribute(ATTR_SCROLL_AMOUNT);
|
|
156
|
+
const value = raw === null || raw.trim() === "" ? NaN : Number(raw);
|
|
157
|
+
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_SCROLL_AMOUNT;
|
|
158
|
+
}
|
|
159
|
+
get scrollDelay() {
|
|
160
|
+
const raw = this.getAttribute(ATTR_SCROLL_DELAY);
|
|
161
|
+
const value = raw === null || raw.trim() === "" ? NaN : Number(raw);
|
|
162
|
+
const delay = Number.isFinite(value) && value >= 0 ? value : DEFAULT_SCROLL_DELAY;
|
|
163
|
+
if (this.hasAttribute(ATTR_TRUE_SPEED)) return delay;
|
|
164
|
+
return Math.max(delay, MIN_SCROLL_DELAY);
|
|
165
|
+
}
|
|
166
|
+
get loop() {
|
|
167
|
+
const value = this.getAttribute(ATTR_LOOP);
|
|
168
|
+
return value === null ? -1 : Number(value);
|
|
169
|
+
}
|
|
170
|
+
get directionSign() {
|
|
171
|
+
return this.direction === "right" || this.direction === "down" ? 1 : -1;
|
|
172
|
+
}
|
|
173
|
+
get isVerticalDirection() {
|
|
174
|
+
return this.direction === "up" || this.direction === "down";
|
|
175
|
+
}
|
|
176
|
+
start() {
|
|
177
|
+
if (this.running) return;
|
|
178
|
+
this.running = true;
|
|
179
|
+
this.lastTime = null;
|
|
180
|
+
this.tick();
|
|
181
|
+
}
|
|
182
|
+
stop() {
|
|
183
|
+
this.running = false;
|
|
184
|
+
if (this.rafId !== null) {
|
|
185
|
+
cancelAnimationFrame(this.rafId);
|
|
186
|
+
this.rafId = null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
syncPresentationalHints() {
|
|
190
|
+
for (const hint of ATTRIBUTE_HINTS) this.syncVar(hint);
|
|
191
|
+
}
|
|
192
|
+
syncVar(hint) {
|
|
193
|
+
const raw = this.getAttribute(hint.attribute);
|
|
194
|
+
const value = hint.parser(raw);
|
|
195
|
+
const fallback = hint.fallback ? hint.fallback(this) : null;
|
|
196
|
+
if (value == null) {
|
|
197
|
+
if (fallback == null) this.style.removeProperty(hint.cssVar);
|
|
198
|
+
else this.style.setProperty(hint.cssVar, fallback);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
this.style.setProperty(hint.cssVar, value);
|
|
202
|
+
}
|
|
203
|
+
reset() {
|
|
204
|
+
const hostSize = this.getHostSize();
|
|
205
|
+
const trackSize = this.getTrackSize();
|
|
206
|
+
this.loopsDone = 0;
|
|
207
|
+
this.forward = true;
|
|
208
|
+
this.position = this.behavior === "alternate" ? this.getAlternateStartPosition(hostSize, trackSize) : this.getStartPosition(hostSize, trackSize);
|
|
209
|
+
this.render();
|
|
210
|
+
}
|
|
211
|
+
getHostSize() {
|
|
212
|
+
return this.isVerticalDirection ? this.clientHeight : this.clientWidth;
|
|
213
|
+
}
|
|
214
|
+
getTrackSize() {
|
|
215
|
+
return this.isVerticalDirection ? this.track.offsetHeight : this.track.offsetWidth;
|
|
216
|
+
}
|
|
217
|
+
getStartPosition(hostSize, trackSize) {
|
|
218
|
+
return this.directionSign < 0 ? hostSize : -trackSize;
|
|
219
|
+
}
|
|
220
|
+
getFlushEndPosition(hostSize, trackSize) {
|
|
221
|
+
return this.directionSign < 0 ? 0 : hostSize - trackSize;
|
|
222
|
+
}
|
|
223
|
+
getOffEndPosition(hostSize, trackSize) {
|
|
224
|
+
return this.directionSign < 0 ? -trackSize : hostSize;
|
|
225
|
+
}
|
|
226
|
+
getSlideEndPosition(hostSize, trackSize) {
|
|
227
|
+
return this.directionSign < 0 ? 0 : hostSize - trackSize;
|
|
228
|
+
}
|
|
229
|
+
getAlternateStartPosition(hostSize, trackSize) {
|
|
230
|
+
return this.directionSign < 0 ? hostSize - trackSize : 0;
|
|
231
|
+
}
|
|
232
|
+
tick(time = performance.now()) {
|
|
233
|
+
if (!this.running) return;
|
|
234
|
+
if (this.lastTime === null) this.lastTime = time;
|
|
235
|
+
if (time - this.lastTime >= this.scrollDelay) {
|
|
236
|
+
this.step();
|
|
237
|
+
this.lastTime = time;
|
|
238
|
+
}
|
|
239
|
+
if (!this.running) return;
|
|
240
|
+
this.rafId = requestAnimationFrame((nextTime) => this.tick(nextTime));
|
|
241
|
+
}
|
|
242
|
+
step() {
|
|
243
|
+
const hostSize = this.getHostSize();
|
|
244
|
+
const trackSize = this.getTrackSize();
|
|
245
|
+
const startPosition = this.getStartPosition(hostSize, trackSize);
|
|
246
|
+
const flushEndPosition = this.getFlushEndPosition(hostSize, trackSize);
|
|
247
|
+
const offEndPosition = this.getOffEndPosition(hostSize, trackSize);
|
|
248
|
+
const slideEndPosition = this.getSlideEndPosition(hostSize, trackSize);
|
|
249
|
+
const alternateStartPosition = this.getAlternateStartPosition(hostSize, trackSize);
|
|
250
|
+
const amount = this.scrollAmount;
|
|
251
|
+
const delta = this.directionSign * amount;
|
|
252
|
+
if (this.behavior === "alternate") {
|
|
253
|
+
this.position += this.forward ? delta : -delta;
|
|
254
|
+
if (this.forward) {
|
|
255
|
+
if (this.directionSign < 0 && this.position <= flushEndPosition || this.directionSign > 0 && this.position >= flushEndPosition) {
|
|
256
|
+
this.position = flushEndPosition;
|
|
257
|
+
this.forward = false;
|
|
258
|
+
this.incrementLoopCount();
|
|
259
|
+
if (this.shouldStopAfterLoop()) this.stop();
|
|
260
|
+
}
|
|
261
|
+
} else if (this.directionSign < 0 && this.position >= alternateStartPosition || this.directionSign > 0 && this.position <= alternateStartPosition) {
|
|
262
|
+
this.position = alternateStartPosition;
|
|
263
|
+
this.forward = true;
|
|
264
|
+
this.incrementLoopCount();
|
|
265
|
+
if (this.shouldStopAfterLoop()) this.stop();
|
|
266
|
+
}
|
|
267
|
+
} else if (this.behavior === "slide") {
|
|
268
|
+
this.position += delta;
|
|
269
|
+
if (this.directionSign < 0 && this.position <= slideEndPosition || this.directionSign > 0 && this.position >= slideEndPosition) {
|
|
270
|
+
this.position = slideEndPosition;
|
|
271
|
+
this.incrementLoopCount();
|
|
272
|
+
if (!this.hasAttribute(ATTR_LOOP) || this.loop <= 0) this.stop();
|
|
273
|
+
else if (this.shouldStopAfterLoop()) this.stop();
|
|
274
|
+
else this.position = startPosition;
|
|
275
|
+
}
|
|
276
|
+
} else {
|
|
277
|
+
this.position += delta;
|
|
278
|
+
if (this.directionSign < 0 && this.position <= offEndPosition || this.directionSign > 0 && this.position >= offEndPosition) {
|
|
279
|
+
this.position = startPosition;
|
|
280
|
+
this.incrementLoopCount();
|
|
281
|
+
if (this.shouldStopAfterLoop()) this.stop();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
this.render();
|
|
285
|
+
}
|
|
286
|
+
incrementLoopCount() {
|
|
287
|
+
this.loopsDone++;
|
|
288
|
+
}
|
|
289
|
+
shouldStopAfterLoop() {
|
|
290
|
+
return this.hasAttribute(ATTR_LOOP) && this.loop > 0 && this.loopsDone >= this.loop;
|
|
291
|
+
}
|
|
292
|
+
render() {
|
|
293
|
+
if (this.isVerticalDirection) this.track.style.transform = `translateY(${this.position}px)`;
|
|
294
|
+
else this.track.style.transform = `translateX(${this.position}px)`;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var defineRemarqueebleElements = () => {
|
|
298
|
+
if (typeof customElements === "undefined") return;
|
|
299
|
+
if (!customElements.get("re-marquee")) customElements.define("re-marquee", RemarqueebleElement);
|
|
300
|
+
if (!customElements.get("re-marquee-ble")) customElements.define("re-marquee-ble", RemarqueebleElement);
|
|
301
|
+
};
|
|
302
|
+
//#endregion
|
|
303
|
+
export { RemarqueebleElement, defineRemarqueebleElements, parseLegacyColor, parsePresentationalDimension };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! remarqueeble v0.1.0 | (c) 2026 Rémino Rem <https://remino.net/> | ISC Licence */
|
|
2
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.remarqueeble={}))})(this,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=globalThis.HTMLElement??class{},T=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},E=[{attribute:h,cssVar:y,parser:T},{attribute:g,cssVar:b,parser:T,fallback(e){return e.isVerticalDirection&&!e.hasAttribute(g)?o:null}},{attribute:_,cssVar:x,parser:T},{attribute:v,cssVar:S,parser:T},{attribute:m,cssVar:C,parser:e=>{if(e===null)return null;let t=e.trim();return t===``?null:globalThis.CSS?.supports(`background-color`,t)?t:null}}],D=class extends w{static observedAttributes=[c,l,u,d,f,p,m,h,g,_,v];track;running=!1;position=0;lastTime=null;loopsDone=0;forward=!0;rafId=null;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
|
+
display: inline-block;
|
|
24
|
+
will-change: transform;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
|
|
28
|
+
<span class="track"><slot></slot></span>
|
|
29
|
+
`;let t=e.querySelector(`.track`);if(!t)throw Error(`Remarqueeble track element was not created.`);this.track=t}connectedCallback(){this.running=!0,this.syncPresentationalHints(),requestAnimationFrame(()=>{!this.isConnected||!this.running||(this.reset(),this.tick())})}disconnectedCallback(){this.running=!1,this.lastTime=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}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.lastTime=null,this.tick())}stop(){this.running=!1,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}syncPresentationalHints(){for(let e of E)this.syncVar(e)}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.loopsDone=0,this.forward=!0,this.position=this.behavior===`alternate`?this.getAlternateStartPosition(e,t):this.getStartPosition(e,t),this.render()}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}tick(e=performance.now()){this.running&&(this.lastTime===null&&(this.lastTime=e),e-this.lastTime>=this.scrollDelay&&(this.step(),this.lastTime=e),this.running&&(this.rafId=requestAnimationFrame(e=>this.tick(e))))}step(){let e=this.getHostSize(),t=this.getTrackSize(),n=this.getStartPosition(e,t),r=this.getFlushEndPosition(e,t),i=this.getOffEndPosition(e,t),a=this.getSlideEndPosition(e,t),o=this.getAlternateStartPosition(e,t),s=this.scrollAmount,c=this.directionSign*s;this.behavior===`alternate`?(this.position+=this.forward?c:-c,this.forward?(this.directionSign<0&&this.position<=r||this.directionSign>0&&this.position>=r)&&(this.position=r,this.forward=!1,this.incrementLoopCount(),this.shouldStopAfterLoop()&&this.stop()):(this.directionSign<0&&this.position>=o||this.directionSign>0&&this.position<=o)&&(this.position=o,this.forward=!0,this.incrementLoopCount(),this.shouldStopAfterLoop()&&this.stop())):this.behavior===`slide`?(this.position+=c,(this.directionSign<0&&this.position<=a||this.directionSign>0&&this.position>=a)&&(this.position=a,this.incrementLoopCount(),!this.hasAttribute(p)||this.loop<=0||this.shouldStopAfterLoop()?this.stop():this.position=n)):(this.position+=c,(this.directionSign<0&&this.position<=i||this.directionSign>0&&this.position>=i)&&(this.position=n,this.incrementLoopCount(),this.shouldStopAfterLoop()&&this.stop())),this.render()}incrementLoopCount(){this.loopsDone++}shouldStopAfterLoop(){return this.hasAttribute(p)&&this.loop>0&&this.loopsDone>=this.loop}render(){this.isVerticalDirection?this.track.style.transform=`translateY(${this.position}px)`:this.track.style.transform=`translateX(${this.position}px)`}},O=()=>{typeof customElements>`u`||(customElements.get(`re-marquee`)||customElements.define(`re-marquee`,D),customElements.get(`re-marquee-ble`)||customElements.define(`re-marquee-ble`,D))};O(),e.defineRemarqueebleElements=O});
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Rémino Rem",
|
|
4
|
+
"url": "https://remino.net/"
|
|
5
|
+
},
|
|
6
|
+
"browser": "dist/remarqueeble.umd.js",
|
|
7
|
+
"description": "Custom element tribute to the cursed glory of marquee.",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@remino/astro-middleware": "^0.1.0",
|
|
10
|
+
"@remino/astro-site-nav": "^0.4.2",
|
|
11
|
+
"@remino/directive": "^5.3.4"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@astrojs/check": "^0.9.4",
|
|
15
|
+
"@eslint/js": "^10.0.1",
|
|
16
|
+
"astro": "^7.0.0",
|
|
17
|
+
"astro-compressor": "^1.3.0",
|
|
18
|
+
"astro-eslint-parser": "^1.4.0",
|
|
19
|
+
"astro-minify-html": "^0.1.1",
|
|
20
|
+
"eslint": "^10.6.0",
|
|
21
|
+
"eslint-config-prettier": "^10.1.8",
|
|
22
|
+
"eslint-plugin-astro": "^1.7.0",
|
|
23
|
+
"globals": "^17.7.0",
|
|
24
|
+
"jasmine": "^6.3.0",
|
|
25
|
+
"prettier": "^3.7.4",
|
|
26
|
+
"prettier-plugin-astro": "^0.14.1",
|
|
27
|
+
"tsx": "^4.22.4",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"typescript-eslint": "^8.62.0",
|
|
30
|
+
"vite": "^8.1.0"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/remarqueeble.d.ts",
|
|
35
|
+
"import": "./dist/remarqueeble.mjs",
|
|
36
|
+
"require": "./dist/remarqueeble.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./auto": {
|
|
39
|
+
"types": "./dist/auto.d.ts",
|
|
40
|
+
"import": "./dist/remarqueeble-auto.mjs",
|
|
41
|
+
"require": "./dist/remarqueeble-auto.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/*"
|
|
46
|
+
],
|
|
47
|
+
"homepage": "https://remino.net/remarqueeble/",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"custom-element",
|
|
50
|
+
"marquee",
|
|
51
|
+
"web-components"
|
|
52
|
+
],
|
|
53
|
+
"license": "ISC",
|
|
54
|
+
"main": "dist/remarqueeble.cjs",
|
|
55
|
+
"module": "dist/remarqueeble.mjs",
|
|
56
|
+
"name": "remarqueeble",
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "npm run js:build && npm run site:assets && astro build",
|
|
59
|
+
"dev": "astro dev",
|
|
60
|
+
"deploy": "rsdeploy -w",
|
|
61
|
+
"deploy:dryrun": "rsdeploy",
|
|
62
|
+
"docs:commit": "export COMMIT=\"$(git rev-parse HEAD)\" && cd deploy && git add . && git commit -m \"Add build for $COMMIT\"; true",
|
|
63
|
+
"docs:publish": "npm run build && npm run docs:commit && npm run deploy && npm run docs:push",
|
|
64
|
+
"docs:push": "cd deploy && git push origin",
|
|
65
|
+
"format": "prettier --write .",
|
|
66
|
+
"format:check": "prettier --check .",
|
|
67
|
+
"js:build": "node bin/build-js.mjs && tsc --emitDeclarationOnly",
|
|
68
|
+
"lib:build": "npm run js:build",
|
|
69
|
+
"lint": "eslint --fix .",
|
|
70
|
+
"lint:check": "eslint .",
|
|
71
|
+
"preview": "astro preview",
|
|
72
|
+
"site:assets": "true",
|
|
73
|
+
"start": "npm run dev",
|
|
74
|
+
"test": "tsx ./node_modules/jasmine/bin/jasmine.js",
|
|
75
|
+
"typecheck": "astro check && tsc --noEmit",
|
|
76
|
+
"version": "npm run build && git add dist"
|
|
77
|
+
},
|
|
78
|
+
"type": "module",
|
|
79
|
+
"types": "dist/remarqueeble.d.ts",
|
|
80
|
+
"version": "0.1.0"
|
|
81
|
+
}
|