marquee-content 5.0.0-dev.2 → 5.0.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/README.md +133 -103
- 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,158 +1,188 @@
|
|
|
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
|
|
13
|
+
|
|
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`.
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
17
23
|
|
|
18
24
|
```bash
|
|
19
|
-
npm
|
|
25
|
+
npm install marquee-content
|
|
20
26
|
```
|
|
21
27
|
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
28
|
```ts
|
|
25
|
-
import
|
|
29
|
+
import 'marquee-content/marquee-content.css'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
Just import the package once - it registers the custom element automatically:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import 'marquee-content'
|
|
28
40
|
```
|
|
29
41
|
|
|
30
42
|
```html
|
|
31
|
-
<marquee-content
|
|
43
|
+
<marquee-content speed="120" mode="auto" direction="rtl">
|
|
32
44
|
<span>News</span>
|
|
33
45
|
<span>Promotions</span>
|
|
34
46
|
<span>24/7 Delivery</span>
|
|
47
|
+
</marquee-content>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you want movement tied to page scroll:
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<marquee-content speed="120" mode="scroll" direction="ltr">
|
|
35
54
|
<span>Discounts up to 40%</span>
|
|
55
|
+
<span>Free returns</span>
|
|
36
56
|
</marquee-content>
|
|
37
57
|
```
|
|
38
58
|
|
|
39
|
-
|
|
59
|
+
---
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
## API
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
- `defineMarqueeContent(tagName?, options?)` — manually registers the element (useful for custom tag names or custom styles at setup time).
|
|
64
|
+
- `initMarqueeContents(options?)` — convenience wrapper around `defineMarqueeContent`.
|
|
65
|
+
- `MarqueeContent.configureStyles({ stylesheet, styleOverrides })` — updates global component styles for every current and future instance.
|
|
66
|
+
- `MARQUEE_CONTENT_TAG` — default tag name (`'marquee-content'`).
|
|
47
67
|
|
|
48
|
-
|
|
49
|
-
plugins: [
|
|
50
|
-
vue({
|
|
51
|
-
template: {
|
|
52
|
-
compilerOptions: {
|
|
53
|
-
isCustomElement: (tag) => tag === 'marquee-content',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
}),
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
```
|
|
68
|
+
---
|
|
60
69
|
|
|
61
|
-
|
|
70
|
+
## Options
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
import { initMarqueeContents } from 'marquee-content';
|
|
72
|
+
Attributes on `<marquee-content>`:
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
| Option | Type | Default | Description |
|
|
75
|
+
|--------|------|---------|-------------|
|
|
76
|
+
| `speed` | `number` | `90` | Base speed in px/s (internally clamped to a safe range). |
|
|
77
|
+
| `mode` | `'auto' \| 'scroll'` | `'auto'` | `auto`: always moves at a constant speed, `scroll`: responds to page scroll velocity. |
|
|
78
|
+
| `direction` | `'rtl' \| 'ltr'` | `'rtl'` | Base movement direction in both `auto` and `scroll` modes. |
|
|
79
|
+
| `pause-on-hover` | `boolean` | `false` | Pauses on hover and enables pointer interactions inside the component. |
|
|
80
|
+
|
|
81
|
+
Init options (`initMarqueeContents` / `defineMarqueeContent`):
|
|
68
82
|
|
|
69
|
-
|
|
83
|
+
| Option | Type | Default | Description |
|
|
84
|
+
|--------|------|---------|-------------|
|
|
85
|
+
| `tagName` | `string` | `'marquee-content'` | Custom element tag name (only for `initMarqueeContents`). |
|
|
86
|
+
| `stylesheet` | `string \| CSSStyleSheet` | bundled CSS | Replaces the default base stylesheet. |
|
|
87
|
+
| `styleOverrides` | `string \| CSSStyleSheet` | none | Extra styles applied after the base stylesheet. |
|
|
70
88
|
|
|
71
|
-
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Methods
|
|
72
92
|
|
|
73
93
|
```ts
|
|
74
|
-
import
|
|
75
|
-
|
|
94
|
+
import type { MarqueeContent } from 'marquee-content'
|
|
95
|
+
|
|
96
|
+
const marquee = document.querySelector<MarqueeContent>('marquee-content')
|
|
97
|
+
|
|
98
|
+
marquee?.update({
|
|
99
|
+
mode: 'scroll',
|
|
100
|
+
direction: 'ltr',
|
|
101
|
+
speed: 120,
|
|
102
|
+
pauseOnHover: true,
|
|
103
|
+
})
|
|
76
104
|
|
|
77
|
-
|
|
78
|
-
styleOverrides: MarqueeOverrides,
|
|
79
|
-
});
|
|
105
|
+
marquee?.refresh()
|
|
80
106
|
```
|
|
81
107
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
:host {
|
|
85
|
-
--marquee-content-gap: 2rem;
|
|
86
|
-
}
|
|
108
|
+
- `update(options)` — applies options as attributes and rebuilds the track.
|
|
109
|
+
- `refresh()` — forces a fresh layout rebuild without changing options.
|
|
87
110
|
|
|
88
|
-
|
|
89
|
-
cursor: default;
|
|
90
|
-
}
|
|
111
|
+
---
|
|
91
112
|
|
|
92
|
-
|
|
93
|
-
white-space: nowrap;
|
|
94
|
-
}
|
|
113
|
+
## Styling
|
|
95
114
|
|
|
96
|
-
|
|
97
|
-
will-change: transform;
|
|
98
|
-
}
|
|
99
|
-
```
|
|
115
|
+
Optional stylesheet import:
|
|
100
116
|
|
|
101
|
-
|
|
117
|
+
```ts
|
|
118
|
+
import 'marquee-content/marquee-content.css'
|
|
119
|
+
```
|
|
102
120
|
|
|
103
|
-
|
|
104
|
-
|:--|:--|:--|:--|
|
|
105
|
-
| `speed` | `number` | `90` | Base speed in px/sec. |
|
|
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
|
|
121
|
+
Runtime style overrides:
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
|
-
import
|
|
124
|
+
import { MarqueeContent } from 'marquee-content'
|
|
125
|
+
|
|
126
|
+
MarqueeContent.configureStyles({
|
|
127
|
+
styleOverrides: `
|
|
128
|
+
:host {
|
|
129
|
+
--marquee-content-gap: 1.25rem;
|
|
130
|
+
}
|
|
131
|
+
`,
|
|
132
|
+
})
|
|
133
|
+
```
|
|
125
134
|
|
|
126
|
-
|
|
135
|
+
Useful CSS variables:
|
|
127
136
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
speed: 120,
|
|
132
|
-
pauseOnHover: true,
|
|
133
|
-
});
|
|
137
|
+
- `--marquee-content-gap`
|
|
138
|
+
- `--marquee-content-distance` (runtime)
|
|
139
|
+
- `--marquee-content-duration` (runtime)
|
|
134
140
|
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
```
|
|
141
|
+
---
|
|
138
142
|
|
|
139
|
-
##
|
|
143
|
+
## Vue 3 + Vite
|
|
144
|
+
|
|
145
|
+
Tell the Vue compiler that `marquee-content` is a custom element:
|
|
140
146
|
|
|
141
147
|
```ts
|
|
142
|
-
import
|
|
148
|
+
import { defineConfig } from 'vite'
|
|
149
|
+
import vue from '@vitejs/plugin-vue'
|
|
143
150
|
|
|
144
|
-
|
|
151
|
+
export default defineConfig({
|
|
152
|
+
plugins: [
|
|
153
|
+
vue({
|
|
154
|
+
template: {
|
|
155
|
+
compilerOptions: {
|
|
156
|
+
isCustomElement: (tag) => tag === 'marquee-content',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
}),
|
|
160
|
+
],
|
|
161
|
+
})
|
|
162
|
+
```
|
|
145
163
|
|
|
146
|
-
|
|
147
|
-
speed: 110,
|
|
148
|
-
direction: 'rtl',
|
|
149
|
-
});
|
|
164
|
+
Then import the package once during app startup:
|
|
150
165
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
marquee?.adoptStyles(':host { color: #fff; }');
|
|
166
|
+
```ts
|
|
167
|
+
import 'marquee-content'
|
|
154
168
|
```
|
|
155
169
|
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Accessibility
|
|
173
|
+
|
|
174
|
+
- Slotted source content stays in the DOM (visually hidden, still available to assistive tech).
|
|
175
|
+
- Cloned decorative content is marked with `aria-hidden`, so screen readers do not announce duplicates.
|
|
176
|
+
- Animation pauses on focus and respects `prefers-reduced-motion: reduce`.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Browser Support
|
|
181
|
+
|
|
182
|
+
Designed for modern browsers with Shadow DOM and constructable/adopted stylesheets support.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
156
186
|
## License
|
|
157
187
|
|
|
158
188
|
MIT
|