use-scroll-animate 2.0.1 → 2.2.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/CHANGELOG.md +27 -0
- package/README.md +31 -1
- package/README_ja.md +18 -0
- package/README_zh.md +31 -0
- package/dist/chunks/base-BiTc85p_.cjs +232 -0
- package/dist/chunks/base-BiTc85p_.cjs.map +1 -0
- package/dist/chunks/base-CFtnmfli.js +219 -0
- package/dist/chunks/base-CFtnmfli.js.map +1 -0
- package/dist/components/background.cjs +395 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +7 -0
- package/dist/components/background.d.cts +132 -0
- package/dist/components/background.d.ts +132 -0
- package/dist/components/background.js +387 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/feedback.cjs +444 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +170 -0
- package/dist/components/feedback.d.ts +170 -0
- package/dist/components/feedback.js +434 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/interaction.cjs +426 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +142 -0
- package/dist/components/interaction.d.ts +142 -0
- package/dist/components/interaction.js +417 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/reveal.cjs +360 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +132 -0
- package/dist/components/reveal.d.ts +132 -0
- package/dist/components/reveal.js +350 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/text.cjs +528 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +7 -0
- package/dist/components/text.d.cts +164 -0
- package/dist/components/text.d.ts +164 -0
- package/dist/components/text.js +517 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/transitions.cjs +546 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +6 -0
- package/dist/components/transitions.d.cts +180 -0
- package/dist/components/transitions.d.ts +180 -0
- package/dist/components/transitions.js +536 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components.cjs +106 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +30 -0
- package/dist/components.d.cts +741 -0
- package/dist/components.d.ts +741 -0
- package/dist/components.js +61 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +22 -0
- package/dist/components.umd.js.map +1 -0
- package/docs/API.md +2 -0
- package/docs/components.md +155 -0
- package/docs/images/showcase-detail.png +0 -0
- package/docs/images/showcase-grid.png +0 -0
- package/docs/images/showcase-mobile.png +0 -0
- package/docs/windows-apps.md +108 -0
- package/package.json +93 -5
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Animated components (`use-scroll-animate/components`)
|
|
2
|
+
|
|
3
|
+
Since **v2.2** the package ships **30 animated UI components** as standard Web Components (`<usa-*>` custom elements) plus three transition helpers. They are built only on Custom Elements, CSS and the Web Animations API, so the same code runs:
|
|
4
|
+
|
|
5
|
+
- in any modern browser (Chrome, Edge, Firefox, Safari), and with React, Vue, Svelte, Solid, Angular or no framework;
|
|
6
|
+
- in **Windows desktop software** that renders its UI with a web view — Electron, Tauri (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs. See **[Windows apps guide](./windows-apps.md)**.
|
|
7
|
+
|
|
8
|
+
Live gallery: <https://harrisoncn.github.io/use-scroll-animate/showcase/components.html>
|
|
9
|
+
|
|
10
|
+
## Principles
|
|
11
|
+
|
|
12
|
+
- **Zero dependencies, tree-shakable.** Import one category (`use-scroll-animate/components/text`) or one component (`import { defineTypewriter } …`) and only that ships.
|
|
13
|
+
- **SSR-safe.** Importing never touches `window`/`document`; every `define*()` is a no-op on the server.
|
|
14
|
+
- **Opt-in registration.** Nothing is registered until you call `define*()` (or load the IIFE bundle). Every `define*()` accepts a custom tag name: `defineSpinner('my-loader')`.
|
|
15
|
+
- **`prefers-reduced-motion` everywhere.** Each component has a calm variant (instant reveal, fade instead of slide, static background…). Override globally with `configureComponents({ reducedMotion: 'reduce' | 'no-preference' | 'user' })`.
|
|
16
|
+
- **GPU-friendly.** Animations use `transform` / `opacity` (plus `filter` for blur effects); layout is read and written in separate phases, at most once per frame, and loops pause when off-screen or the tab is hidden.
|
|
17
|
+
- **Accessible.** Animated text keeps a visually-hidden plain copy for screen readers; switches, progress bars, toasts and dialogs carry the right roles and ARIA states.
|
|
18
|
+
- **Styles included.** Each component injects its own small stylesheet once (as a constructable stylesheet, which a `style-src 'self'` CSP allows). Prefer a file? `import 'use-scroll-animate/components.css'` (or `/components/<category>.css`) and call `configureComponents({ injectStyles: false })`.
|
|
19
|
+
|
|
20
|
+
## Install & register
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm i use-scroll-animate
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
// everything
|
|
28
|
+
import { defineComponents } from 'use-scroll-animate/components';
|
|
29
|
+
defineComponents(); // or defineComponents(['text', 'feedback'])
|
|
30
|
+
|
|
31
|
+
// one category
|
|
32
|
+
import { defineTextComponents } from 'use-scroll-animate/components/text';
|
|
33
|
+
defineTextComponents();
|
|
34
|
+
|
|
35
|
+
// one component
|
|
36
|
+
import { defineTypewriter } from 'use-scroll-animate/components/text';
|
|
37
|
+
defineTypewriter();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
No build step (registers every `<usa-*>` and exposes the API as `window.UsaComponents`):
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<script src="https://unpkg.com/use-scroll-animate@2/dist/components.umd.js"></script>
|
|
44
|
+
<usa-typewriter words="Hello, Windows.|Hello, web."></usa-typewriter>
|
|
45
|
+
<script>UsaComponents.toast('Ready', { type: 'success' });</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Entry | Contents |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `use-scroll-animate/components` | everything + `defineComponents()`, `COMPONENT_CATEGORIES`, `configureComponents()` |
|
|
51
|
+
| `use-scroll-animate/components/reveal` · `/text` · `/interaction` · `/feedback` · `/background` · `/transitions` | one category + `define<Category>Components()` |
|
|
52
|
+
| `use-scroll-animate/components.css`, `/components/<category>.css` | the same styles as files |
|
|
53
|
+
| `dist/components.umd.js` | IIFE/UMD bundle for `<script>` tags, auto-registers |
|
|
54
|
+
|
|
55
|
+
## Components by category
|
|
56
|
+
|
|
57
|
+
All attributes are optional unless noted. Events are `CustomEvent`s that bubble, named `usa:*`.
|
|
58
|
+
|
|
59
|
+
### 1. Entrance & scroll — `components/reveal`
|
|
60
|
+
|
|
61
|
+
| Element | What it does | Key attributes | JS API / events |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| `<usa-reveal>` | Reveals content when it enters the viewport | `effect` (`fade`, `fade-up`*, `fade-down`, `fade-left`, `fade-right`, `zoom-in`, `zoom-out`, `blur`, `blur-up`, `flip-up`, `flip-left`, `rise`), `duration` (700), `delay`, `distance` (32), `easing`, `threshold` (0.15), `root-margin`, `repeat` | `reveal()`, `reset()`, `revealed`; `usa:enter`, `usa:leave`, `usa:complete` |
|
|
64
|
+
| `<usa-stagger>` | Reveals its children one after another | `effect`, `interval` (70 ms), `duration`, `delay`, `distance`, `threshold`, `repeat` | `reveal()`, `reset()`; `usa:enter`, `usa:complete` |
|
|
65
|
+
| `<usa-scroll-progress>` | Reading-progress bar for the page or one article | `target` (selector), `position` (`top`*, `bottom`, `inline`), `label`; CSS `--usa-progress-color/-height/-track` | `progress`, `update()`; `usa:progress` (`detail.progress`); `--usa-progress` on the element |
|
|
66
|
+
| `<usa-scrolly>` | Sticky scrollytelling: `[data-sticky]` stays pinned while `[data-step]` children scroll by | `offset` (trigger line, 0.5) | `active`, `steps`; `usa:step` (`detail.index/step/name`); `data-step-name` + `--usa-step` on the host, `data-active` on the step |
|
|
67
|
+
|
|
68
|
+
### 2. Text — `components/text`
|
|
69
|
+
|
|
70
|
+
| Element | What it does | Key attributes | JS API / events |
|
|
71
|
+
|---|---|---|---|
|
|
72
|
+
| `<usa-typewriter>` | Types text, or cycles phrases (type → pause → delete) | `text` or `words` (`a\|b\|c`), `speed` (55), `delete-speed` (30), `pause` (1400), `delay`, `loop`, `cursor="false"`, `start` (`view`*, `load`, `manual`) | `start()`, `stop()`, `restart()`; `usa:complete` |
|
|
73
|
+
| `<usa-split-text>` | Splits into characters or words and cascades them in | `by` (`chars`*, `words`), `effect` (`rise`*, `fade`, `blur`, `flip`, `pop`), `stagger`, `duration` (620), `delay`, `trigger` (`view`*, `load`, `manual`), `repeat` | `play()`, `reset()`, `units`; `usa:complete` |
|
|
74
|
+
| `<usa-scramble>` | Decodes text out of random glyphs | `text`, `duration` (900), `chars`, `trigger` (`view`*, `hover`, `load`, `manual`) | `play()`; `usa:complete` |
|
|
75
|
+
| `<usa-counter>` | Counts to a number when visible (locale-formatted, tabular digits) | `to` (required), `from`, `duration` (1600), `decimals`, `locale`, `prefix`, `suffix`, `grouping="false"`, `start` | `value` (set to animate), `play(to?)`, `format(n)`; `usa:complete` |
|
|
76
|
+
| `<usa-shimmer-text>` | Light sweep across gradient text (CSS only) | `duration` (2600), `color`, `shine`, `angle` | — |
|
|
77
|
+
| `<usa-text-rotate>` | Cycles words in place without reflow | `words`, `interval` (2200), `effect` (`slide`*, `fade`, `flip`, `blur`), `paused` | `next()`, `index`; `usa:change` |
|
|
78
|
+
|
|
79
|
+
### 3. Interaction — `components/interaction`
|
|
80
|
+
|
|
81
|
+
| Element | What it does | Key attributes | JS API / events |
|
|
82
|
+
|---|---|---|---|
|
|
83
|
+
| `<usa-ripple>` | Ink ripple from the pointer (centre for Space/Enter) | `color`, `opacity` (0.22), `duration` (550), `centered`, `disabled`, `block` | `ripple(x?, y?)` |
|
|
84
|
+
| `<usa-magnetic>` | Content leans toward a nearby pointer and springs back | `strength` (0.35), `radius` (60), `disabled` | — (fine pointers only) |
|
|
85
|
+
| `<usa-tilt>` | 3D tilt toward the pointer, optional glare | `max` (10°), `scale` (1.03), `perspective` (900), `glare`, `reverse`, `disabled` | `--usa-tilt-x/-y` (−1…1) for inner parallax |
|
|
86
|
+
| `<usa-spotlight>` | Windows Fluent **Reveal highlight**: light follows the pointer across a group, lighting borders | `size` (160), `color`, `border` (1), `no-fill`; items = children or `[data-spotlight]` | — |
|
|
87
|
+
| `<usa-press>` | Press feedback: dip + spring back, or `bounce` | `scale` (0.95), `bounce`, `disabled`, `block` | `pressed` |
|
|
88
|
+
| `<usa-toggle>` | Windows 11-style switch, form-associated | `checked`, `disabled`, `name`, `value`, `label` | `checked`, `toggle(force?)`; `change`, `usa:change` |
|
|
89
|
+
|
|
90
|
+
### 4. Loading & feedback — `components/feedback`
|
|
91
|
+
|
|
92
|
+
| Element | What it does | Key attributes | JS API / events |
|
|
93
|
+
|---|---|---|---|
|
|
94
|
+
| `<usa-spinner>` | Indeterminate indicators | `variant` (`fluent`* = WinUI ProgressRing, `windows` = Windows 10 orbiting dots, `ring`, `dots`, `pulse`, `bars`), `size` (32), `label`, `paused` | `variant` |
|
|
95
|
+
| `<usa-skeleton>` | Shimmer placeholders; content fades in when loading ends | `loading`, `lines` (3), `avatar`, `circle`, `width`, `height`, `radius` | `loading`; `usa:loaded` |
|
|
96
|
+
| `<usa-progress>` | Linear progress; Fluent indeterminate animation without a value | `value`, `max` (100), `indeterminate`, `state` (`paused`, `error`), `label` | `value`, `max`, `ratio`; `usa:complete` |
|
|
97
|
+
| `<usa-toaster>` + `toast()` | Notifications that slide in, pause on hover, stack with FLIP | `position` (`bottom-right`*, `bottom-left`, `bottom-center`, `top-*`), `max` (4), `label` | `toast(msg, { type, duration, action, dismissible })` → `{ element, close() }`; `show()`, `clear()` |
|
|
98
|
+
| `<usa-check>` | Animated success / error / warning icon | `variant` (`success`*, `error`, `warning`), `size` (56), `start`, `label` | `play()`, `reset()`; `usa:complete` |
|
|
99
|
+
|
|
100
|
+
### 5. Background & decoration — `components/background`
|
|
101
|
+
|
|
102
|
+
| Element | What it does | Key attributes | JS API / events |
|
|
103
|
+
|---|---|---|---|
|
|
104
|
+
| `<usa-aurora>` | Drifting aurora / gradient mesh behind content | `colors` (comma list), `speed` (1), `intensity` (0.7), `paused` | — (pauses off-screen) |
|
|
105
|
+
| `<usa-particles>` | Canvas constellation that avoids the pointer | `count` (60), `color`, `size`, `speed`, `links` (110, `0` = off), `interactive`, `paused` | `reset()` |
|
|
106
|
+
| `<usa-grain>` | SVG-noise film-grain overlay | `opacity` (0.12), `animated`, `blend`, `scale` | — |
|
|
107
|
+
| `<usa-marquee>` | Seamless infinite ticker | `speed` (50 px/s), `direction` (`left`*, `right`, `up`, `down`), `gap`, `pause-on-hover`, `fade`, `paused` | `pause()`, `resume()` |
|
|
108
|
+
| `<usa-acrylic>` | Fluent **Acrylic** / **Mica** materials | `variant` (`acrylic`*, `mica`), `tint`, `tint-opacity`, `blur`, `shimmer` (`hover`, `load`) | — (solid under `prefers-reduced-transparency` / forced colours) |
|
|
109
|
+
|
|
110
|
+
### 6. Transitions — `components/transitions`
|
|
111
|
+
|
|
112
|
+
| Element / helper | What it does | Key attributes / options | JS API / events |
|
|
113
|
+
|---|---|---|---|
|
|
114
|
+
| `<usa-dialog>` | Animated modal / drawer / sheet on the native `<dialog>` (focus trap, Esc, top layer); content is slotted, so frameworks keep owning it | `open`, `variant` (`modal`*, `drawer-start`, `drawer-end`, `drawer-bottom`, `sheet`), `label`, `no-backdrop-close`, `no-esc`; `[data-close]` children close it; `::part(panel/backdrop)`, `--usa-dialog-*` | `show()`, `close(value?)`, `open`, `returnValue`; `usa:open`, `usa:beforeclose` (cancelable), `usa:close` |
|
|
115
|
+
| `<usa-accordion>` | Smooth height animation for native `<details>` | `multiple`, `duration` (300) | `toggleItem(details, open?)`, `items`; `usa:toggle` |
|
|
116
|
+
| `<usa-flip-list>` | Children glide to new places on add / remove / reorder (FLIP) | `duration` (420), `easing`, `disabled` | `flip(mutate)` |
|
|
117
|
+
| `<usa-view-switch>` | One view at a time with direction-aware transitions | `active` (name or index), `effect` (`slide`*, `fade`, `scale`, `drill`), `duration` | `show(view)`, `active`, `views`; `usa:change` |
|
|
118
|
+
| `viewTransition(update, opts?)` | Runs a DOM update inside `document.startViewTransition()`, cross-fade fallback | `{ fallback, duration, types }` | `Promise<void>` |
|
|
119
|
+
| `flip(targets, mutate, opts?)` | FLIP-animates any layout change | `{ duration, easing, animateEnter }` | `Promise<void>` |
|
|
120
|
+
| `connectedAnimation(from, to, opts?)` | WinUI-style connected / shared-element animation | `{ duration, easing, hideSource }` | `Promise<void>` |
|
|
121
|
+
|
|
122
|
+
## Frameworks
|
|
123
|
+
|
|
124
|
+
Custom elements work in every framework. Register once (e.g. in your entry file), then use the tags.
|
|
125
|
+
|
|
126
|
+
```jsx
|
|
127
|
+
// React 19 passes props to custom elements as properties; React 18 passes strings — both work for attributes.
|
|
128
|
+
import { defineFeedbackComponents, toast } from 'use-scroll-animate/components/feedback';
|
|
129
|
+
defineFeedbackComponents();
|
|
130
|
+
|
|
131
|
+
export function Save() {
|
|
132
|
+
return <button onClick={() => toast('Saved', { type: 'success' })}>Save <usa-spinner variant="dots" size="16" /></button>;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
// Vue (vite.config.js): tell the compiler these are custom elements
|
|
138
|
+
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('usa-') } } });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
TypeScript: the entries augment `HTMLElementTagNameMap`, so `document.querySelector('usa-dialog')` is typed as `UsaDialogElement`.
|
|
142
|
+
|
|
143
|
+
## Size
|
|
144
|
+
|
|
145
|
+
Gzipped, minified (budgets enforced in CI by `npm run size:check`):
|
|
146
|
+
|
|
147
|
+
| Import | gzip |
|
|
148
|
+
|---|---:|
|
|
149
|
+
| `dist/components.umd.js` (all 30 + CSS) | ≈ 22 kB |
|
|
150
|
+
| one category (`components/text`, …) | 3.5 – 6.4 kB |
|
|
151
|
+
| one component (`defineTypewriter`, `defineReveal`, `defineRipple`, …) | ≈ 1.8 – 2.5 kB |
|
|
152
|
+
| `viewTransition` only | ≈ 0.4 kB |
|
|
153
|
+
| `dist/components.css` | ≈ 5.5 kB |
|
|
154
|
+
|
|
155
|
+
The scroll-animation core (`use-scroll-animate`) is unchanged and is not pulled in by the components.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Using the components in Windows desktop apps
|
|
2
|
+
|
|
3
|
+
The `<usa-*>` components are plain web platform code (Custom Elements v1, CSS, Web Animations API). Any Windows app whose UI is rendered by a modern web engine can use them unchanged:
|
|
4
|
+
|
|
5
|
+
| Stack | Engine on Windows | Works | Notes |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| **Electron** | Chromium (bundled) | ✅ | All features, incl. View Transitions. |
|
|
8
|
+
| **Tauri 1/2** | Microsoft Edge **WebView2** (Chromium) | ✅ | Same as Edge. |
|
|
9
|
+
| **WinUI 3 / WPF / WinForms + WebView2** | WebView2 | ✅ | Host a local HTML page (see below). |
|
|
10
|
+
| **.NET MAUI / Blazor Hybrid** | `BlazorWebView` → WebView2 | ✅ | Register in `wwwroot/index.html`. |
|
|
11
|
+
| **Installed PWA** (Edge / Chrome "Install app") | Edge / Chrome | ✅ | Runs in its own window with taskbar icon. |
|
|
12
|
+
| Neutralino, Wails, Flutter `webview_windows` | WebView2 | ✅ | Any WebView2-based shell. |
|
|
13
|
+
| Legacy MSHTML (`WebBrowser` control, IE11) | Trident | ❌ | No Custom Elements / WAAPI — migrate to WebView2. |
|
|
14
|
+
|
|
15
|
+
Requirements: Custom Elements, `IntersectionObserver` and `Element.animate()` — every Chromium ≥ 84 (all supported Electron/WebView2 versions). `viewTransition()` uses the View Transitions API (Chromium ≥ 111) and falls back to a cross-fade.
|
|
16
|
+
|
|
17
|
+
Every component respects the Windows setting **Settings → Accessibility → Visual effects → Animation effects** (exposed to web views as `prefers-reduced-motion`), and `<usa-acrylic>` turns solid when **Transparency effects** are off or a high-contrast theme is active (`prefers-reduced-transparency`, `forced-colors`).
|
|
18
|
+
|
|
19
|
+
## Electron
|
|
20
|
+
|
|
21
|
+
Bundle the renderer as usual (Vite, webpack, esbuild…):
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
// renderer/main.js
|
|
25
|
+
import { defineComponents, toast } from 'use-scroll-animate/components';
|
|
26
|
+
defineComponents();
|
|
27
|
+
|
|
28
|
+
window.api?.onSaved?.(() => toast('Saved', { type: 'success' }));
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<!-- renderer/index.html -->
|
|
33
|
+
<usa-acrylic variant="mica" style="min-height:100vh">
|
|
34
|
+
<usa-view-switch active="home">
|
|
35
|
+
<section data-view="home"><usa-typewriter words="Welcome back"></usa-typewriter></section>
|
|
36
|
+
<section data-view="settings"><usa-toggle checked>Start with Windows</usa-toggle></section>
|
|
37
|
+
</usa-view-switch>
|
|
38
|
+
</usa-acrylic>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Without a bundler, copy `node_modules/use-scroll-animate/dist/components.umd.js` next to your HTML and use `<script src="components.umd.js"></script>` — no `nodeIntegration` needed, it works with `contextIsolation: true` and `sandbox: true`.
|
|
42
|
+
|
|
43
|
+
**Content-Security-Policy.** Components inject styles via constructable stylesheets (`document.adoptedStyleSheets`), which are allowed by `style-src 'self'` without `'unsafe-inline'`. If you prefer files:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import 'use-scroll-animate/components.css';
|
|
47
|
+
import { configureComponents, defineComponents } from 'use-scroll-animate/components';
|
|
48
|
+
configureComponents({ injectStyles: false });
|
|
49
|
+
defineComponents();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`<usa-grain>` and `<usa-acrylic>` use `data:` SVG noise images — allow `img-src 'self' data:`.
|
|
53
|
+
|
|
54
|
+
**Real Windows materials.** Electron ≥ 24 can draw real Mica / Acrylic behind a transparent window (`new BrowserWindow({ backgroundMaterial: 'mica' })`). Set the page background to transparent and use `<usa-acrylic tint-opacity="0.2">` for in-page panels on top of it.
|
|
55
|
+
|
|
56
|
+
## Tauri
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
// src/main.ts (Vite template)
|
|
60
|
+
import { defineFeedbackComponents } from 'use-scroll-animate/components/feedback';
|
|
61
|
+
import { defineTransitionComponents } from 'use-scroll-animate/components/transitions';
|
|
62
|
+
defineFeedbackComponents();
|
|
63
|
+
defineTransitionComponents();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Nothing to configure in `tauri.conf.json`. For window-level Mica/Acrylic use Tauri's `windowEffects` (`"effects": ["mica"]`) with `"transparent": true`.
|
|
67
|
+
|
|
68
|
+
## WinUI 3 / WPF / WinForms with WebView2
|
|
69
|
+
|
|
70
|
+
1. Put your page and the bundle in a folder that is copied to the output, e.g. `wwwroot/index.html` and `wwwroot/components.umd.js` (from `node_modules/use-scroll-animate/dist/`, or download it from unpkg).
|
|
71
|
+
2. Map the folder to a virtual host and navigate to it:
|
|
72
|
+
|
|
73
|
+
```csharp
|
|
74
|
+
// WinUI 3 (C#)
|
|
75
|
+
await MyWebView.EnsureCoreWebView2Async();
|
|
76
|
+
MyWebView.CoreWebView2.SetVirtualHostNameToFolderMapping(
|
|
77
|
+
"app.local", Path.Combine(AppContext.BaseDirectory, "wwwroot"),
|
|
78
|
+
CoreWebView2HostResourceAccessKind.Allow);
|
|
79
|
+
MyWebView.Source = new Uri("https://app.local/index.html");
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<!-- wwwroot/index.html -->
|
|
84
|
+
<!doctype html>
|
|
85
|
+
<meta name="color-scheme" content="light dark">
|
|
86
|
+
<script src="components.umd.js"></script>
|
|
87
|
+
<usa-progress id="p" value="0" label="Installing"></usa-progress>
|
|
88
|
+
<usa-spinner variant="fluent"></usa-spinner>
|
|
89
|
+
<script>
|
|
90
|
+
// messages from C#: CoreWebView2.PostWebMessageAsJson("{\"progress\":42}")
|
|
91
|
+
chrome.webview.addEventListener('message', (e) => (p.value = e.data.progress));
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Talk back to the host with `chrome.webview.postMessage(...)` from component events, e.g.
|
|
96
|
+
`dialog.addEventListener('usa:close', (e) => chrome.webview.postMessage({ closed: e.detail.returnValue }))`.
|
|
97
|
+
|
|
98
|
+
For a transparent WebView2 over a Mica window, set `DefaultBackgroundColor` to `Transparent` and keep the page background transparent.
|
|
99
|
+
|
|
100
|
+
## PWA
|
|
101
|
+
|
|
102
|
+
Link the bundle (or import it in your module graph) and install the site from Edge/Chrome. Add `"display": "standalone"` (or `"window-controls-overlay"` for a custom title bar) to the manifest; the components behave exactly as on the web.
|
|
103
|
+
|
|
104
|
+
## Performance checklist for desktop UIs
|
|
105
|
+
|
|
106
|
+
- Register only what you use (`define<Category>Components()` or single `define*()` calls) to keep start-up light.
|
|
107
|
+
- Background effects (`<usa-aurora>`, `<usa-particles>`, `<usa-marquee>`) stop animating when off-screen and when the window is hidden/minimised (`document.hidden`).
|
|
108
|
+
- All motion runs on the compositor (`transform` / `opacity`), so it stays smooth on integrated GPUs and in battery-saver mode; call `configureComponents({ reducedMotion: 'reduce' })` to force the calm variants (e.g. for a "Reduce animations" toggle in your app settings).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-scroll-animate",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "A lightweight, high-performance, dependency-free scroll animation library for
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "A lightweight, high-performance, dependency-free scroll animation library and animated UI components (Web Components) for the web and Windows web-view apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"unpkg": "dist/index.umd.js",
|
|
@@ -68,6 +68,83 @@
|
|
|
68
68
|
"default": "./dist/element.cjs"
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
|
+
"./components": {
|
|
72
|
+
"import": {
|
|
73
|
+
"types": "./dist/components.d.ts",
|
|
74
|
+
"default": "./dist/components.js"
|
|
75
|
+
},
|
|
76
|
+
"require": {
|
|
77
|
+
"types": "./dist/components.d.cts",
|
|
78
|
+
"default": "./dist/components.cjs"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"./components/reveal": {
|
|
82
|
+
"import": {
|
|
83
|
+
"types": "./dist/components/reveal.d.ts",
|
|
84
|
+
"default": "./dist/components/reveal.js"
|
|
85
|
+
},
|
|
86
|
+
"require": {
|
|
87
|
+
"types": "./dist/components/reveal.d.cts",
|
|
88
|
+
"default": "./dist/components/reveal.cjs"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"./components/text": {
|
|
92
|
+
"import": {
|
|
93
|
+
"types": "./dist/components/text.d.ts",
|
|
94
|
+
"default": "./dist/components/text.js"
|
|
95
|
+
},
|
|
96
|
+
"require": {
|
|
97
|
+
"types": "./dist/components/text.d.cts",
|
|
98
|
+
"default": "./dist/components/text.cjs"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"./components/interaction": {
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./dist/components/interaction.d.ts",
|
|
104
|
+
"default": "./dist/components/interaction.js"
|
|
105
|
+
},
|
|
106
|
+
"require": {
|
|
107
|
+
"types": "./dist/components/interaction.d.cts",
|
|
108
|
+
"default": "./dist/components/interaction.cjs"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"./components/feedback": {
|
|
112
|
+
"import": {
|
|
113
|
+
"types": "./dist/components/feedback.d.ts",
|
|
114
|
+
"default": "./dist/components/feedback.js"
|
|
115
|
+
},
|
|
116
|
+
"require": {
|
|
117
|
+
"types": "./dist/components/feedback.d.cts",
|
|
118
|
+
"default": "./dist/components/feedback.cjs"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"./components/background": {
|
|
122
|
+
"import": {
|
|
123
|
+
"types": "./dist/components/background.d.ts",
|
|
124
|
+
"default": "./dist/components/background.js"
|
|
125
|
+
},
|
|
126
|
+
"require": {
|
|
127
|
+
"types": "./dist/components/background.d.cts",
|
|
128
|
+
"default": "./dist/components/background.cjs"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"./components/transitions": {
|
|
132
|
+
"import": {
|
|
133
|
+
"types": "./dist/components/transitions.d.ts",
|
|
134
|
+
"default": "./dist/components/transitions.js"
|
|
135
|
+
},
|
|
136
|
+
"require": {
|
|
137
|
+
"types": "./dist/components/transitions.d.cts",
|
|
138
|
+
"default": "./dist/components/transitions.cjs"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"./components.css": "./dist/components.css",
|
|
142
|
+
"./components/reveal.css": "./dist/components/reveal.css",
|
|
143
|
+
"./components/text.css": "./dist/components/text.css",
|
|
144
|
+
"./components/interaction.css": "./dist/components/interaction.css",
|
|
145
|
+
"./components/feedback.css": "./dist/components/feedback.css",
|
|
146
|
+
"./components/background.css": "./dist/components/background.css",
|
|
147
|
+
"./components/transitions.css": "./dist/components/transitions.css",
|
|
71
148
|
"./package.json": "./package.json"
|
|
72
149
|
},
|
|
73
150
|
"files": [
|
|
@@ -79,14 +156,16 @@
|
|
|
79
156
|
"LICENSE",
|
|
80
157
|
"CHANGELOG.md"
|
|
81
158
|
],
|
|
82
|
-
"sideEffects":
|
|
159
|
+
"sideEffects": [
|
|
160
|
+
"*.css"
|
|
161
|
+
],
|
|
83
162
|
"scripts": {
|
|
84
163
|
"build": "npm run clean && rollup -c rollup.config.mjs",
|
|
85
164
|
"dev": "rollup -c rollup.config.mjs -w",
|
|
86
165
|
"typecheck": "tsc --noEmit -p .",
|
|
87
166
|
"test": "vitest run",
|
|
88
167
|
"check:exports": "node scripts/check-exports.mjs",
|
|
89
|
-
"lint:package": "publint && attw --pack . --profile node16",
|
|
168
|
+
"lint:package": "publint && attw --pack . --profile node16 --exclude-entrypoints ./components.css ./components/reveal.css ./components/text.css ./components/interaction.css ./components/feedback.css ./components/background.css ./components/transitions.css",
|
|
90
169
|
"size": "node scripts/size.mjs",
|
|
91
170
|
"prepublishOnly": "npm run typecheck && npm test && npm run build && npm run check:exports",
|
|
92
171
|
"size:check": "node scripts/size.mjs --check",
|
|
@@ -108,7 +187,16 @@
|
|
|
108
187
|
"solid",
|
|
109
188
|
"web-component",
|
|
110
189
|
"custom-element",
|
|
111
|
-
"scroll-timeline"
|
|
190
|
+
"scroll-timeline",
|
|
191
|
+
"animated-components",
|
|
192
|
+
"ui-components",
|
|
193
|
+
"electron",
|
|
194
|
+
"tauri",
|
|
195
|
+
"webview2",
|
|
196
|
+
"fluent",
|
|
197
|
+
"typewriter",
|
|
198
|
+
"skeleton",
|
|
199
|
+
"toast"
|
|
112
200
|
],
|
|
113
201
|
"author": "HarrisonCN",
|
|
114
202
|
"license": "MIT",
|