marquee-content 6.0.0 → 6.0.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.
- package/README.md +60 -81
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,35 +7,13 @@ A Web Component for decorative text tickers, logo strips, and continuous image r
|
|
|
7
7
|
|
|
8
8
|
[Demo](https://codepen.io/nilmuse/pen/dygzqYm)
|
|
9
9
|
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Features
|
|
13
|
-
|
|
14
|
-
- A `<marquee-content>` custom element for plain HTML and framework applications.
|
|
15
|
-
- Continuous motion in either direction, using CSS animation in `auto` mode.
|
|
16
|
-
- A `scroll` mode that changes direction and speed with page scrolling, then eases back to its base speed.
|
|
17
|
-
- Optional hover pausing and automatic pausing outside the viewport.
|
|
18
|
-
- A static, wrapping presentation when the user prefers reduced motion.
|
|
19
|
-
- Styling through inherited host properties, CSS variables, and `::part()`.
|
|
20
|
-
- Automatic layout updates for source content, images, fonts, and size changes.
|
|
21
|
-
|
|
22
|
-
### Supported content
|
|
23
|
-
|
|
24
|
-
Use the component for decorative text and images. The rendered row consists of copies of the supplied content; those copies are hidden from assistive technology and inert. Keep links, buttons, forms, and other interactive controls outside the moving row.
|
|
25
|
-
|
|
26
|
-
Apply text styles to the host and item styles through the exposed CSS parts. The component copies markup, including custom `part` tokens; event listeners, application state, and document-level class selectors are not a styling or interaction contract for the rendered copies.
|
|
27
|
-
|
|
28
|
-
---
|
|
29
|
-
|
|
30
10
|
## Installation
|
|
31
11
|
|
|
32
12
|
```bash
|
|
33
13
|
npm install marquee-content
|
|
34
14
|
```
|
|
35
15
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## Quick Start
|
|
16
|
+
## Quick start
|
|
39
17
|
|
|
40
18
|
Import the package in your browser entry point. This registers the default tag and installs its Shadow DOM styles:
|
|
41
19
|
|
|
@@ -59,18 +37,7 @@ marquee-content {
|
|
|
59
37
|
}
|
|
60
38
|
```
|
|
61
39
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
```html
|
|
65
|
-
<marquee-content speed="120" mode="scroll" direction="ltr">
|
|
66
|
-
<span>New collection</span>
|
|
67
|
-
<span>Made to move</span>
|
|
68
|
-
</marquee-content>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
`scroll` listens to the window's vertical scroll position. Its direction follows scrolling, and its speed boost decays after scrolling stops. A custom scroll container is not currently configurable.
|
|
72
|
-
|
|
73
|
-
---
|
|
40
|
+
In the default `auto` mode, the row moves continuously using CSS animation. Layout updates automatically when source content, images, fonts, or sizes change.
|
|
74
41
|
|
|
75
42
|
## API
|
|
76
43
|
|
|
@@ -95,9 +62,7 @@ initMarqueeContents({
|
|
|
95
62
|
|
|
96
63
|
Calling a registration helper is only needed for an additional tag or global style setup.
|
|
97
64
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
## Options
|
|
65
|
+
### Options
|
|
101
66
|
|
|
102
67
|
| Option (HTML / JavaScript) | Type | Default | Description |
|
|
103
68
|
| --- | --- | --- | --- |
|
|
@@ -109,7 +74,41 @@ Calling a registration helper is only needed for an additional tag or global sty
|
|
|
109
74
|
|
|
110
75
|
Boolean attributes accept `true` or `false`; an empty attribute enables the option. Removing an attribute restores its default.
|
|
111
76
|
|
|
112
|
-
###
|
|
77
|
+
### Methods
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import 'marquee-content';
|
|
81
|
+
|
|
82
|
+
const marquee = document.querySelector('marquee-content');
|
|
83
|
+
|
|
84
|
+
marquee?.update({
|
|
85
|
+
mode: 'scroll',
|
|
86
|
+
direction: 'ltr',
|
|
87
|
+
speed: 120,
|
|
88
|
+
responsiveSpeed: false,
|
|
89
|
+
pauseOnHover: true,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
marquee?.refresh();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- `update(options)` applies options as attributes and updates the animation settings.
|
|
96
|
+
- `refresh()` schedules a fresh layout measurement. Use it after application-driven changes that need an explicit refresh.
|
|
97
|
+
|
|
98
|
+
## Scroll response
|
|
99
|
+
|
|
100
|
+
To react to page scrolling:
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<marquee-content speed="120" mode="scroll" direction="ltr">
|
|
104
|
+
<span>New collection</span>
|
|
105
|
+
<span>Made to move</span>
|
|
106
|
+
</marquee-content>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`scroll` listens to the window's vertical scroll position. Its direction follows scrolling, and its speed boost decays after scrolling stops. A custom scroll container is not currently configurable.
|
|
110
|
+
|
|
111
|
+
## Speed on narrow screens
|
|
113
112
|
|
|
114
113
|
Responsive speed is enabled by default. It uses the **component's width**, in CSS pixels:
|
|
115
114
|
|
|
@@ -117,7 +116,7 @@ Responsive speed is enabled by default. It uses the **component's width**, in CS
|
|
|
117
116
|
effective speed = speed × clamp(component width / 1280, 0.55, 1)
|
|
118
117
|
```
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
Below a component width of about `700px`, speed stays at 55% of the configured value — about `50px/s` with the default `speed="90"`. At `1280px` and above, it uses the configured speed without scaling.
|
|
121
120
|
|
|
122
121
|
For the same base speed on mobile and desktop, disable scaling:
|
|
123
122
|
|
|
@@ -139,38 +138,7 @@ if (marquee) {
|
|
|
139
138
|
|
|
140
139
|
In `auto` mode, this gives `90px/s`. In `scroll` mode, `90px/s` is the base speed; scrolling and inertia intentionally change it.
|
|
141
140
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
## Methods
|
|
145
|
-
|
|
146
|
-
```ts
|
|
147
|
-
import 'marquee-content';
|
|
148
|
-
|
|
149
|
-
const marquee = document.querySelector('marquee-content');
|
|
150
|
-
|
|
151
|
-
marquee?.update({
|
|
152
|
-
mode: 'scroll',
|
|
153
|
-
direction: 'ltr',
|
|
154
|
-
speed: 120,
|
|
155
|
-
responsiveSpeed: false,
|
|
156
|
-
pauseOnHover: true,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
marquee?.refresh();
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
- `update(options)` applies options as attributes and updates the animation settings.
|
|
163
|
-
- `refresh()` schedules a fresh layout measurement. Use it after application-driven changes that need an explicit refresh.
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## Framework integration
|
|
168
|
-
|
|
169
|
-
### Server-rendered applications
|
|
170
|
-
|
|
171
|
-
The module can be imported when browser globals are unavailable. Custom element registration and construction require a browser. Render the declarative tag in server-generated HTML and ensure the package also runs in the browser entry point; the animated Shadow DOM track is built there.
|
|
172
|
-
|
|
173
|
-
### Vue 3 + Vite
|
|
141
|
+
## Vue 3 with Vite
|
|
174
142
|
|
|
175
143
|
Tell Vue's compiler to treat the tag as a custom element:
|
|
176
144
|
|
|
@@ -191,14 +159,21 @@ export default defineConfig({
|
|
|
191
159
|
});
|
|
192
160
|
```
|
|
193
161
|
|
|
194
|
-
Then
|
|
162
|
+
Then render it in a component:
|
|
195
163
|
|
|
196
|
-
```
|
|
164
|
+
```vue
|
|
165
|
+
<script setup lang="ts">
|
|
197
166
|
import 'marquee-content';
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<template>
|
|
170
|
+
<marquee-content speed="120">
|
|
171
|
+
<span>New collection</span>
|
|
172
|
+
<span>Made to move</span>
|
|
173
|
+
</marquee-content>
|
|
174
|
+
</template>
|
|
198
175
|
```
|
|
199
176
|
|
|
200
|
-
---
|
|
201
|
-
|
|
202
177
|
## Styling
|
|
203
178
|
|
|
204
179
|
Base styles ship in the JavaScript bundle and are adopted into each component's Shadow DOM. No separate CSS import is required. A sidecar stylesheet is also exported as `marquee-content/marquee-content.css` for tooling that needs it.
|
|
@@ -283,7 +258,11 @@ MarqueeContent.configureStyles({
|
|
|
283
258
|
|
|
284
259
|
Use host styles and `::part()` for individual instances. The runtime configuration above is shared globally.
|
|
285
260
|
|
|
286
|
-
|
|
261
|
+
## Supported content
|
|
262
|
+
|
|
263
|
+
Use the component for decorative text and images. The rendered row consists of copies of the supplied content; those copies are hidden from assistive technology and inert. Keep links, buttons, forms, and other interactive controls outside the moving row.
|
|
264
|
+
|
|
265
|
+
Apply text styles to the host and item styles through the exposed CSS parts. The component copies markup, including custom `part` tokens; event listeners, application state, and document-level class selectors are not a styling or interaction contract for the rendered copies.
|
|
287
266
|
|
|
288
267
|
## Accessibility and motion
|
|
289
268
|
|
|
@@ -292,13 +271,13 @@ Use host styles and `::part()` for individual instances. The runtime configurati
|
|
|
292
271
|
- `prefers-reduced-motion: reduce` presents one static, wrapping set of the content so all items can be seen without animation. CSS parts continue to apply.
|
|
293
272
|
- Movement pauses outside the viewport, on focus within the component, and on hover when `pause-on-hover` is enabled.
|
|
294
273
|
|
|
295
|
-
|
|
274
|
+
## Server-rendered applications
|
|
296
275
|
|
|
297
|
-
|
|
276
|
+
The module can be imported when browser globals are unavailable. Custom element registration and construction require a browser. Render the declarative tag in server-generated HTML and ensure the package also runs in the browser entry point; the animated Shadow DOM track is built there.
|
|
298
277
|
|
|
299
|
-
|
|
278
|
+
## Browser support
|
|
300
279
|
|
|
301
|
-
|
|
280
|
+
The component uses Custom Elements, Shadow DOM, constructable/adopted stylesheets, ResizeObserver, IntersectionObserver, and `inert`. The `scroll` mode also uses the Web Animations API. Use a browser that supports these APIs; legacy-browser fallbacks are not included.
|
|
302
281
|
|
|
303
282
|
## License
|
|
304
283
|
|