marquee-content 5.0.0-dev.2 → 5.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 +130 -102
- package/dist/index.cjs +643 -58
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +134 -0
- package/dist/index.d.ts +134 -4
- package/dist/index.js +647 -0
- package/dist/index.js.map +1 -0
- package/dist/marquee-content.css +1 -1
- package/package.json +49 -29
- package/dist/index.es.js +0 -558
- package/dist/index.umd.js +0 -71
- package/dist/marquee-content.d.ts +0 -166
- package/dist/styles.d.ts +0 -10
package/README.md
CHANGED
|
@@ -1,157 +1,185 @@
|
|
|
1
1
|
# marquee-content
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- Works with plain HTML via custom element registration.
|
|
6
|
-
- Supports `rtl`, `ltr`, and `scroll` direction modes.
|
|
7
|
-
- Supports `pause-on-hover`, viewport pause, reduced motion, and responsive speed.
|
|
8
|
-
- Supports CSS overrides via `styleOverrides`.
|
|
9
|
-
- 6kB gzipped.
|
|
10
|
-
- [Demo](https://codepen.io/ux-ui/pen/dygzqYm).
|
|
3
|
+
Simple Web Component for marquee/ticker rows with smooth, continuous motion.
|
|
11
4
|
|
|
12
5
|
[](https://www.npmjs.com/package/marquee-content)
|
|
13
|
-
[](https://www.npmjs.com/package/marquee-content)
|
|
7
|
+
|
|
8
|
+
[Demo](https://codepen.io/ux-ui/pen/dygzqYm)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
- Drop-in Custom Element (`<marquee-content>`) that works in plain HTML.
|
|
15
|
+
- Two movement modes: `auto` (pure CSS) and `scroll` (reacts to page scroll + inertia).
|
|
16
|
+
- `rtl`/`ltr` direction support in both modes.
|
|
17
|
+
- Smart pausing on hover, focus, out-of-viewport, and reduced-motion settings.
|
|
18
|
+
- Easy style control via CSS variables or runtime `styleOverrides`.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
17
23
|
|
|
18
24
|
```bash
|
|
19
|
-
npm
|
|
25
|
+
npm install marquee-content
|
|
20
26
|
```
|
|
21
27
|
|
|
22
|
-
|
|
28
|
+
Optional stylesheet (sidecar):
|
|
23
29
|
|
|
24
30
|
```ts
|
|
25
|
-
import
|
|
31
|
+
import 'marquee-content/marquee-content.css';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
Import the package once — it registers the custom element and applies bundled Shadow DOM styles automatically:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import 'marquee-content';
|
|
28
42
|
```
|
|
29
43
|
|
|
30
44
|
```html
|
|
31
|
-
<marquee-content
|
|
45
|
+
<marquee-content speed="120" mode="auto" direction="rtl">
|
|
32
46
|
<span>News</span>
|
|
33
47
|
<span>Promotions</span>
|
|
34
48
|
<span>24/7 Delivery</span>
|
|
49
|
+
</marquee-content>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you want movement tied to page scroll:
|
|
53
|
+
|
|
54
|
+
```html
|
|
55
|
+
<marquee-content speed="120" mode="scroll" direction="ltr">
|
|
35
56
|
<span>Discounts up to 40%</span>
|
|
57
|
+
<span>Free returns</span>
|
|
36
58
|
</marquee-content>
|
|
37
59
|
```
|
|
38
60
|
|
|
39
|
-
|
|
61
|
+
---
|
|
40
62
|
|
|
41
|
-
|
|
63
|
+
## API
|
|
42
64
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
- `defineMarqueeContent(tagName?, options?)` — manually registers the element (useful for custom tag names or custom styles at setup time).
|
|
66
|
+
- `initMarqueeContents(options?)` — convenience wrapper around `defineMarqueeContent`.
|
|
67
|
+
- `MarqueeContent.configureStyles({ stylesheet, styleOverrides })` — updates global component styles for every current and future instance.
|
|
68
|
+
- `MARQUEE_CONTENT_TAG` — default tag name (`'marquee-content'`).
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
plugins: [
|
|
50
|
-
vue({
|
|
51
|
-
template: {
|
|
52
|
-
compilerOptions: {
|
|
53
|
-
isCustomElement: (tag) => tag === 'marquee-content',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
```
|
|
70
|
+
---
|
|
60
71
|
|
|
61
|
-
|
|
72
|
+
## Options
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
import { initMarqueeContents } from 'marquee-content';
|
|
74
|
+
Attributes on `<marquee-content>`:
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
| Option | Type | Default | Description |
|
|
77
|
+
|--------|------|---------|-------------|
|
|
78
|
+
| `speed` | `number` | `90` | Base speed in px/s (internally clamped to a safe range). |
|
|
79
|
+
| `mode` | `'auto' \| 'scroll'` | `'auto'` | `auto`: always moves at a constant speed, `scroll`: responds to page scroll velocity. |
|
|
80
|
+
| `direction` | `'rtl' \| 'ltr'` | `'rtl'` | Base movement direction in both `auto` and `scroll` modes. |
|
|
81
|
+
| `pause-on-hover` | `boolean` | `false` | Pauses on hover and enables pointer interactions inside the component. |
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
Init options (`initMarqueeContents` / `defineMarqueeContent`):
|
|
70
84
|
|
|
71
|
-
|
|
85
|
+
| Option | Type | Default | Description |
|
|
86
|
+
|--------|------|---------|-------------|
|
|
87
|
+
| `tagName` | `string` | `'marquee-content'` | Custom element tag name (only for `initMarqueeContents`). |
|
|
88
|
+
| `stylesheet` | `string \| CSSStyleSheet` | bundled CSS | Replaces the default base stylesheet. |
|
|
89
|
+
| `styleOverrides` | `string \| CSSStyleSheet` | none | Extra styles applied after the base stylesheet. |
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Methods
|
|
72
94
|
|
|
73
95
|
```ts
|
|
74
|
-
import
|
|
75
|
-
|
|
96
|
+
import type { MarqueeContent } from 'marquee-content'
|
|
97
|
+
|
|
98
|
+
const marquee = document.querySelector<MarqueeContent>('marquee-content')
|
|
76
99
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
marquee?.update({
|
|
101
|
+
mode: 'scroll',
|
|
102
|
+
direction: 'ltr',
|
|
103
|
+
speed: 120,
|
|
104
|
+
pauseOnHover: true,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
marquee?.refresh()
|
|
80
108
|
```
|
|
81
109
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
110
|
+
- `update(options)` — applies options as attributes and rebuilds the track.
|
|
111
|
+
- `refresh()` — forces a fresh layout rebuild without changing options.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Styling
|
|
87
116
|
|
|
88
|
-
|
|
89
|
-
cursor: default;
|
|
90
|
-
}
|
|
117
|
+
Base styles ship with the JS bundle and are adopted into each component's Shadow DOM. You do not need a separate CSS import for the marquee to work.
|
|
91
118
|
|
|
92
|
-
|
|
93
|
-
white-space: nowrap;
|
|
94
|
-
}
|
|
119
|
+
Runtime style overrides:
|
|
95
120
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
121
|
+
```ts
|
|
122
|
+
import { MarqueeContent } from 'marquee-content';
|
|
123
|
+
|
|
124
|
+
MarqueeContent.configureStyles({
|
|
125
|
+
styleOverrides: `
|
|
126
|
+
:host {
|
|
127
|
+
--marquee-content-gap: 1.25rem;
|
|
128
|
+
}
|
|
129
|
+
`,
|
|
130
|
+
})
|
|
99
131
|
```
|
|
100
132
|
|
|
101
|
-
|
|
133
|
+
Useful CSS variables:
|
|
102
134
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| `direction` | `'rtl' \| 'ltr' \| 'scroll'` | `'rtl'` | Marquee direction mode. |
|
|
107
|
-
| `min-group-width-ratio` | `number` | `1.05` | Minimum content group width relative to container. |
|
|
108
|
-
| `responsive-speed` | `boolean` | `true` | Enables speed scaling by container width. |
|
|
109
|
-
| `reference-width` | `number` | `1280` | Reference width used for responsive speed factor. |
|
|
110
|
-
| `min-speed-factor` | `number` | `0.55` | Lower bound for responsive speed multiplier. |
|
|
111
|
-
| `max-speed-factor` | `number` | `1` | Upper bound for responsive speed multiplier. |
|
|
112
|
-
| `pause-on-hover` | `boolean` | `false` | Pauses animation while hovered. |
|
|
113
|
-
| `pause-when-out-of-view` | `boolean` | `true` | Pauses animation when not visible in viewport. |
|
|
114
|
-
| `recalculate-after-fonts-ready` | `boolean` | `true` | Rebuilds marquee when document fonts are ready. |
|
|
115
|
-
| `scroll-velocity-factor` | `number` | `400` | Normalizes scroll velocity for `direction="scroll"`. |
|
|
116
|
-
| `scroll-min-extra-speed` | `number` | `0.15` | Minimum scroll boost threshold. |
|
|
117
|
-
| `scroll-max-extra-speed` | `number` | `3` | Maximum absolute scroll boost. |
|
|
118
|
-
| `scroll-inertia-duration` | `number` | `1600` | Inertia duration (ms) for scroll boost fade-out. |
|
|
119
|
-
| `debug` | `boolean` | `false` | Enables debug logs in console. |
|
|
120
|
-
|
|
121
|
-
### Programmatic update
|
|
135
|
+
- `--marquee-content-gap`
|
|
136
|
+
- `--marquee-content-distance` (runtime)
|
|
137
|
+
- `--marquee-content-duration` (runtime)
|
|
122
138
|
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Vue 3 + Vite
|
|
125
142
|
|
|
126
|
-
|
|
143
|
+
Tell the Vue compiler that `marquee-content` is a custom element:
|
|
127
144
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
speed: 120,
|
|
132
|
-
pauseOnHover: true,
|
|
133
|
-
});
|
|
145
|
+
```ts
|
|
146
|
+
import { defineConfig } from 'vite'
|
|
147
|
+
import vue from '@vitejs/plugin-vue'
|
|
134
148
|
|
|
135
|
-
|
|
136
|
-
|
|
149
|
+
export default defineConfig({
|
|
150
|
+
plugins: [
|
|
151
|
+
vue({
|
|
152
|
+
template: {
|
|
153
|
+
compilerOptions: {
|
|
154
|
+
isCustomElement: (tag) => tag === 'marquee-content',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
],
|
|
159
|
+
})
|
|
137
160
|
```
|
|
138
161
|
|
|
139
|
-
|
|
162
|
+
Then import the package once during app startup:
|
|
140
163
|
|
|
141
164
|
```ts
|
|
142
|
-
import
|
|
165
|
+
import 'marquee-content';
|
|
166
|
+
```
|
|
143
167
|
|
|
144
|
-
|
|
168
|
+
---
|
|
145
169
|
|
|
146
|
-
|
|
147
|
-
speed: 110,
|
|
148
|
-
direction: 'rtl',
|
|
149
|
-
});
|
|
170
|
+
## Accessibility
|
|
150
171
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
- Slotted source content stays in the DOM (visually hidden, still available to assistive tech).
|
|
173
|
+
- Cloned decorative content is marked with `aria-hidden`, so screen readers do not announce duplicates.
|
|
174
|
+
- Animation pauses on focus and respects `prefers-reduced-motion: reduce`.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Browser Support
|
|
179
|
+
|
|
180
|
+
Designed for modern browsers with Shadow DOM and constructable/adopted stylesheets support.
|
|
181
|
+
|
|
182
|
+
---
|
|
155
183
|
|
|
156
184
|
## License
|
|
157
185
|
|