use-scroll-animate 4.8.0 → 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/CHANGELOG.md +33 -0
- package/README.md +2 -1
- package/README_ja.md +1 -0
- package/README_zh.md +2 -1
- package/bin/usa-codemod-5.mjs +79 -0
- package/dist/chunks/{base-CxYU2NK_.cjs → base-B5i8qQPR.cjs} +65 -30
- package/dist/chunks/base-B5i8qQPR.cjs.map +1 -0
- package/dist/chunks/{base-CZiIAMBc.js → base-C3Sw9sAO.js} +63 -31
- package/dist/chunks/base-C3Sw9sAO.js.map +1 -0
- package/dist/chunks/{core-HLqH3qkA.cjs → core-BDcszY4L.cjs} +2 -2
- package/dist/chunks/{core-HLqH3qkA.cjs.map → core-BDcszY4L.cjs.map} +1 -1
- package/dist/chunks/{core-COi3DrLx.js → core-BTf__I-8.js} +2 -2
- package/dist/chunks/{core-COi3DrLx.js.map → core-BTf__I-8.js.map} +1 -1
- package/dist/chunks/{core-CctNfzuP.cjs → core-BjOYKSrV.cjs} +2 -2
- package/dist/chunks/{core-CctNfzuP.cjs.map → core-BjOYKSrV.cjs.map} +1 -1
- package/dist/chunks/{core-CJHJeMI_.js → core-DN3hHbHh.js} +2 -2
- package/dist/chunks/{core-CJHJeMI_.js.map → core-DN3hHbHh.js.map} +1 -1
- package/dist/chunks/fx-B8hk1Fby.cjs +114 -0
- package/dist/chunks/fx-B8hk1Fby.cjs.map +1 -0
- package/dist/chunks/fx-ChjxrMBo.js +109 -0
- package/dist/chunks/fx-ChjxrMBo.js.map +1 -0
- package/dist/chunks/{index-tags-Dh8nwXqw.js → index-tags-DucKMQr_.js} +2 -1
- package/dist/chunks/{index-tags-Dh8nwXqw.js.map → index-tags-DucKMQr_.js.map} +1 -1
- package/dist/chunks/{index-tags-CIRY2KnU.cjs → index-tags-wv0R_vkO.cjs} +2 -1
- package/dist/chunks/{index-tags-CIRY2KnU.cjs.map → index-tags-wv0R_vkO.cjs.map} +1 -1
- package/dist/chunks/{spring-Dkpygsuj.cjs → spring--oZh55tB.cjs} +2 -2
- package/dist/chunks/{spring-Dkpygsuj.cjs.map → spring--oZh55tB.cjs.map} +1 -1
- package/dist/chunks/{spring-BS5tg6aK.js → spring-CckMe3x0.js} +2 -2
- package/dist/chunks/{spring-BS5tg6aK.js.map → spring-CckMe3x0.js.map} +1 -1
- package/dist/chunks/{variants-D9n-3x27.js → variants-Bsevy6Xm.js} +2 -2
- package/dist/chunks/{variants-D9n-3x27.js.map → variants-Bsevy6Xm.js.map} +1 -1
- package/dist/chunks/{variants-CfJzrzMh.cjs → variants-DxPmgrNX.cjs} +2 -2
- package/dist/chunks/{variants-CfJzrzMh.cjs.map → variants-DxPmgrNX.cjs.map} +1 -1
- package/dist/components/a11y.cjs +39 -2
- package/dist/components/a11y.cjs.map +1 -1
- package/dist/components/a11y.d.cts +13 -2
- package/dist/components/a11y.d.ts +13 -2
- package/dist/components/a11y.js +39 -4
- package/dist/components/a11y.js.map +1 -1
- package/dist/components/angular.cjs +8 -6
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +33 -4
- package/dist/components/angular.d.ts +33 -4
- package/dist/components/angular.js +8 -6
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs +2 -4
- package/dist/components/background.cjs.map +1 -1
- package/dist/components/background.d.cts +2 -47
- package/dist/components/background.d.ts +2 -47
- package/dist/components/background.js +3 -4
- package/dist/components/background.js.map +1 -1
- package/dist/components/bridge.cjs +1 -1
- package/dist/components/bridge.js +1 -1
- package/dist/components/cards.cjs +2 -4
- package/dist/components/cards.cjs.map +1 -1
- package/dist/components/cards.d.cts +2 -47
- package/dist/components/cards.d.ts +2 -47
- package/dist/components/cards.js +2 -3
- package/dist/components/cards.js.map +1 -1
- package/dist/components/click.cjs +24 -130
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.d.cts +2 -47
- package/dist/components/click.d.ts +2 -47
- package/dist/components/click.js +4 -109
- package/dist/components/click.js.map +1 -1
- package/dist/components/depth.cjs +3 -5
- package/dist/components/depth.cjs.map +1 -1
- package/dist/components/depth.d.cts +2 -47
- package/dist/components/depth.d.ts +2 -47
- package/dist/components/depth.js +3 -4
- package/dist/components/depth.js.map +1 -1
- package/dist/components/feedback.cjs +1 -3
- package/dist/components/feedback.cjs.map +1 -1
- package/dist/components/feedback.d.cts +2 -47
- package/dist/components/feedback.d.ts +2 -47
- package/dist/components/feedback.js +1 -2
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/fx.cjs +285 -0
- package/dist/components/fx.cjs.map +1 -0
- package/dist/components/fx.css +3 -0
- package/dist/components/fx.d.cts +114 -0
- package/dist/components/fx.d.ts +114 -0
- package/dist/components/fx.js +271 -0
- package/dist/components/fx.js.map +1 -0
- package/dist/components/gesture.cjs +3 -5
- package/dist/components/gesture.cjs.map +1 -1
- package/dist/components/gesture.d.cts +2 -47
- package/dist/components/gesture.d.ts +2 -47
- package/dist/components/gesture.js +4 -5
- package/dist/components/gesture.js.map +1 -1
- package/dist/components/interaction.cjs +1 -3
- package/dist/components/interaction.cjs.map +1 -1
- package/dist/components/interaction.d.cts +2 -47
- package/dist/components/interaction.d.ts +2 -47
- package/dist/components/interaction.js +1 -2
- package/dist/components/interaction.js.map +1 -1
- package/dist/components/jsx.d.cts +1 -0
- package/dist/components/jsx.d.ts +1 -0
- package/dist/components/layout.cjs +1 -3
- package/dist/components/layout.cjs.map +1 -1
- package/dist/components/layout.d.cts +2 -47
- package/dist/components/layout.d.ts +2 -47
- package/dist/components/layout.js +2 -3
- package/dist/components/layout.js.map +1 -1
- package/dist/components/lazy.cjs +2 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.d.cts +1 -0
- package/dist/components/lazy.d.ts +1 -0
- package/dist/components/lazy.js +2 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/lite.cjs +413 -42
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +394 -43
- package/dist/components/lite.js.map +1 -1
- package/dist/components/packs.cjs +1 -3
- package/dist/components/packs.cjs.map +1 -1
- package/dist/components/packs.d.cts +2 -47
- package/dist/components/packs.d.ts +2 -47
- package/dist/components/packs.js +2 -3
- package/dist/components/packs.js.map +1 -1
- package/dist/components/page.cjs +31 -12
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.d.cts +15 -52
- package/dist/components/page.d.ts +15 -52
- package/dist/components/page.js +31 -12
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs +3 -4
- package/dist/components/perf.cjs.map +1 -1
- package/dist/components/perf.d.cts +1 -0
- package/dist/components/perf.d.ts +1 -0
- package/dist/components/perf.js +4 -5
- package/dist/components/perf.js.map +1 -1
- package/dist/components/physics.cjs +2 -4
- package/dist/components/physics.cjs.map +1 -1
- package/dist/components/physics.d.cts +2 -47
- package/dist/components/physics.d.ts +2 -47
- package/dist/components/physics.js +3 -4
- package/dist/components/physics.js.map +1 -1
- package/dist/components/react.cjs +1 -1
- package/dist/components/react.js +1 -1
- package/dist/components/reveal.cjs +1 -3
- package/dist/components/reveal.cjs.map +1 -1
- package/dist/components/reveal.d.cts +2 -47
- package/dist/components/reveal.d.ts +2 -47
- package/dist/components/reveal.js +1 -2
- package/dist/components/reveal.js.map +1 -1
- package/dist/components/solid.cjs +8 -6
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +33 -4
- package/dist/components/solid.d.ts +33 -4
- package/dist/components/solid.js +8 -6
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +8 -6
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +33 -4
- package/dist/components/svelte.d.ts +33 -4
- package/dist/components/svelte.js +8 -6
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs +1 -3
- package/dist/components/svg.cjs.map +1 -1
- package/dist/components/svg.d.cts +2 -47
- package/dist/components/svg.d.ts +2 -47
- package/dist/components/svg.js +2 -3
- package/dist/components/svg.js.map +1 -1
- package/dist/components/text.cjs +2 -4
- package/dist/components/text.cjs.map +1 -1
- package/dist/components/text.d.cts +2 -47
- package/dist/components/text.d.ts +2 -47
- package/dist/components/text.js +2 -3
- package/dist/components/text.js.map +1 -1
- package/dist/components/timeline.cjs +3 -5
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.d.cts +4 -49
- package/dist/components/timeline.d.ts +4 -49
- package/dist/components/timeline.js +4 -5
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/transitions.cjs +1 -3
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.d.cts +2 -47
- package/dist/components/transitions.d.ts +2 -47
- package/dist/components/transitions.js +2 -3
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.cjs +3 -5
- package/dist/components/ui.cjs.map +1 -1
- package/dist/components/ui.d.cts +2 -47
- package/dist/components/ui.d.ts +2 -47
- package/dist/components/ui.js +4 -5
- package/dist/components/ui.js.map +1 -1
- package/dist/components/vue.cjs +8 -6
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +33 -4
- package/dist/components/vue.d.ts +33 -4
- package/dist/components/vue.js +8 -6
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs +3 -5
- package/dist/components/webgl.cjs.map +1 -1
- package/dist/components/webgl.d.cts +2 -47
- package/dist/components/webgl.d.ts +2 -47
- package/dist/components/webgl.js +3 -4
- package/dist/components/webgl.js.map +1 -1
- package/dist/components.cjs +33 -10
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +1 -0
- package/dist/components.d.cts +147 -17
- package/dist/components.d.ts +147 -17
- package/dist/components.js +16 -12
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/docs/API.md +1 -1
- package/docs/ROADMAP.md +12 -12
- package/docs/components.md +14 -1
- package/docs/deprecations.md +6 -0
- package/docs/performance.md +1 -1
- package/docs/upgrading-5.md +31 -0
- package/package.json +18 -3
- package/dist/chunks/base-CZiIAMBc.js.map +0 -1
- package/dist/chunks/base-CxYU2NK_.cjs.map +0 -1
package/dist/components/lite.js
CHANGED
|
@@ -7,10 +7,16 @@
|
|
|
7
7
|
* scripts. Classes are created the first time a `define*()` function runs.
|
|
8
8
|
*/
|
|
9
9
|
const MOTION_SENSITIVITY_LEVELS = ['full', 'gentle', 'minimal', 'static'];
|
|
10
|
-
const MOTION_SCALE = {
|
|
10
|
+
const MOTION_SCALE = { low: 0.6, normal: 1, high: 1.25 };
|
|
11
11
|
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };
|
|
12
12
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
13
13
|
function configureComponents(options) {
|
|
14
|
+
options = { ...options };
|
|
15
|
+
// 5.0: removed values are ignored (see docs/upgrading-5.md)
|
|
16
|
+
if (options.motionIntensity && !(options.motionIntensity in MOTION_SCALE))
|
|
17
|
+
delete options.motionIntensity;
|
|
18
|
+
if (options.reducedMotion && options.reducedMotion !== 'reduce')
|
|
19
|
+
options.reducedMotion = 'user';
|
|
14
20
|
Object.assign(config, options);
|
|
15
21
|
if (options.motionIntensity && typeof document !== 'undefined') {
|
|
16
22
|
document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
|
|
@@ -55,6 +61,14 @@ function adaptKeyframes(frames, level = config.motionSensitivity) {
|
|
|
55
61
|
return out;
|
|
56
62
|
});
|
|
57
63
|
}
|
|
64
|
+
/** Run `fn` without 4.9 deprecation warnings (library-internal calls). */
|
|
65
|
+
function withoutDeprecations(fn) {
|
|
66
|
+
try {
|
|
67
|
+
return fn();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
58
72
|
/** The current global motion intensity. */
|
|
59
73
|
function getMotionIntensity() {
|
|
60
74
|
return config.motionIntensity;
|
|
@@ -66,10 +80,10 @@ function motionScale() {
|
|
|
66
80
|
const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
|
|
67
81
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
68
82
|
function prefersReducedMotion() {
|
|
69
|
-
if (config.
|
|
83
|
+
if (config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static')
|
|
84
|
+
return true;
|
|
85
|
+
if (config.reducedMotion === 'reduce')
|
|
70
86
|
return true;
|
|
71
|
-
if (config.reducedMotion !== 'user')
|
|
72
|
-
return config.reducedMotion === 'reduce';
|
|
73
87
|
return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
74
88
|
}
|
|
75
89
|
const injected = new Set();
|
|
@@ -205,31 +219,7 @@ function getBase() {
|
|
|
205
219
|
}
|
|
206
220
|
/** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */
|
|
207
221
|
motion(el, keyframes, options) {
|
|
208
|
-
|
|
209
|
-
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
keyframes = adaptKeyframes(keyframes);
|
|
213
|
-
if (active$1 >= maxActive) {
|
|
214
|
-
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
const k = motionScale();
|
|
218
|
-
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
219
|
-
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
220
|
-
const a = el.animate(keyframes, options);
|
|
221
|
-
if (options.iterations !== Infinity) {
|
|
222
|
-
active$1++;
|
|
223
|
-
let done = false;
|
|
224
|
-
const end = () => {
|
|
225
|
-
if (!done) {
|
|
226
|
-
done = true;
|
|
227
|
-
active$1--;
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
a?.finished?.then(end, end);
|
|
231
|
-
}
|
|
232
|
-
return a;
|
|
222
|
+
return animateWithMotion(el, keyframes, options);
|
|
233
223
|
}
|
|
234
224
|
emit(type, detail) {
|
|
235
225
|
return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
|
|
@@ -238,6 +228,39 @@ function getBase() {
|
|
|
238
228
|
baseClass = Base;
|
|
239
229
|
return baseClass;
|
|
240
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* `el.animate()` with the library's motion rules (5.0, shared by elements and
|
|
233
|
+
* registered effects): motion sensitivity (keyframes adapted, `static` →
|
|
234
|
+
* final frame), intensity (duration scale) and the animation budget. Returns
|
|
235
|
+
* `null` (final frame applied) when nothing should animate.
|
|
236
|
+
*/
|
|
237
|
+
function animateWithMotion(el, keyframes, options) {
|
|
238
|
+
if (typeof el.animate !== 'function' || config.motionSensitivity === 'static') {
|
|
239
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
keyframes = adaptKeyframes(keyframes);
|
|
243
|
+
if (active$1 >= maxActive) {
|
|
244
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
const k = motionScale();
|
|
248
|
+
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
249
|
+
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
250
|
+
const a = el.animate(keyframes, options);
|
|
251
|
+
if (options.iterations !== Infinity) {
|
|
252
|
+
active$1++;
|
|
253
|
+
let done = false;
|
|
254
|
+
const end = () => {
|
|
255
|
+
if (!done) {
|
|
256
|
+
done = true;
|
|
257
|
+
active$1--;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
a?.finished?.then(end, end);
|
|
261
|
+
}
|
|
262
|
+
return a;
|
|
263
|
+
}
|
|
241
264
|
/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */
|
|
242
265
|
function applyFrame(el, frame) {
|
|
243
266
|
if (!frame)
|
|
@@ -358,6 +381,15 @@ const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
|
358
381
|
const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
|
|
359
382
|
/** Windows Fluent "decelerate" / "point-to-point" curves. */
|
|
360
383
|
const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';
|
|
384
|
+
const warned = new Set();
|
|
385
|
+
/** Log a deprecation once per key (console.warn). */
|
|
386
|
+
function deprecate(key, message) {
|
|
387
|
+
if (warned.has(key))
|
|
388
|
+
return;
|
|
389
|
+
warned.add(key);
|
|
390
|
+
if (typeof console !== 'undefined')
|
|
391
|
+
console.warn(`[use-scroll-animate] ${message}`);
|
|
392
|
+
}
|
|
361
393
|
/**
|
|
362
394
|
* The `kind` attribute of `<usa-spinner>`, `<usa-check>`, `<usa-dialog>` and
|
|
363
395
|
* `<usa-acrylic>` (3.0: `variant` only selects a style variant).
|
|
@@ -389,6 +421,7 @@ const COMPONENT_CATEGORIES = {
|
|
|
389
421
|
depth: ['usa-cube', 'usa-depth'],
|
|
390
422
|
layout: ['usa-auto-animate', 'usa-masonry'],
|
|
391
423
|
packs: ['usa-pack'],
|
|
424
|
+
fx: ['usa-fx'],
|
|
392
425
|
};
|
|
393
426
|
|
|
394
427
|
/**
|
|
@@ -424,8 +457,7 @@ function autoDegrade(options = {}) {
|
|
|
424
457
|
state.reason = reason;
|
|
425
458
|
if (degraded) {
|
|
426
459
|
prev = { intensity: getMotionIntensity(), budget: animationBudget() };
|
|
427
|
-
|
|
428
|
-
configureComponents({ motionIntensity: 'low' });
|
|
460
|
+
configureComponents({ motionIntensity: 'low' });
|
|
429
461
|
setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));
|
|
430
462
|
}
|
|
431
463
|
else if (prev) {
|
|
@@ -7941,18 +7973,23 @@ function defineAutoSkeleton(tag = 'usa-auto-skeleton') {
|
|
|
7941
7973
|
|
|
7942
7974
|
var css$7 = "";
|
|
7943
7975
|
|
|
7976
|
+
const INTENSITIES = ['low', 'normal', 'high'];
|
|
7944
7977
|
const LEVELS = ['off', 'low', 'normal', 'high'];
|
|
7945
7978
|
const KEY$1 = 'usa:motion';
|
|
7946
7979
|
/**
|
|
7947
7980
|
* Set the global motion intensity for every `<usa-*>` component:
|
|
7948
|
-
* `'
|
|
7949
|
-
*
|
|
7950
|
-
*
|
|
7981
|
+
* `'low'`, `'normal'` (default), `'high'`. Sets `--usa-motion` and
|
|
7982
|
+
* `data-usa-motion` on `<html>`; with `persist` the choice is remembered
|
|
7983
|
+
* (localStorage) and restored by `restoreMotionIntensity()`.
|
|
7984
|
+
* 5.0: `'off'` was removed — use `setMotionSensitivity('minimal')`.
|
|
7951
7985
|
*/
|
|
7952
7986
|
function setMotionIntensity(level, persist = false) {
|
|
7953
|
-
if (!
|
|
7987
|
+
if (!INTENSITIES.includes(level))
|
|
7954
7988
|
return;
|
|
7955
7989
|
configureComponents({ motionIntensity: level });
|
|
7990
|
+
store(level, persist);
|
|
7991
|
+
}
|
|
7992
|
+
function store(level, persist) {
|
|
7956
7993
|
if (persist) {
|
|
7957
7994
|
try {
|
|
7958
7995
|
localStorage.setItem(KEY$1, level);
|
|
@@ -7964,12 +8001,26 @@ function setMotionIntensity(level, persist = false) {
|
|
|
7964
8001
|
if (typeof document !== 'undefined')
|
|
7965
8002
|
document.dispatchEvent(new CustomEvent('usa:motion', { detail: { level } }));
|
|
7966
8003
|
}
|
|
7967
|
-
/**
|
|
8004
|
+
/** Apply a switch level: `'off'` = motion sensitivity `minimal`, otherwise full motion at that intensity. */
|
|
8005
|
+
function setMotionLevel(level, persist = false) {
|
|
8006
|
+
if (!LEVELS.includes(level))
|
|
8007
|
+
return;
|
|
8008
|
+
if (level === 'off')
|
|
8009
|
+
configureComponents({ motionSensitivity: 'minimal' });
|
|
8010
|
+
else
|
|
8011
|
+
configureComponents({ motionIntensity: level, ...(getMotionSensitivity() === 'minimal' ? { motionSensitivity: 'full' } : {}) });
|
|
8012
|
+
store(level, persist);
|
|
8013
|
+
}
|
|
8014
|
+
/** The current switch level. */
|
|
8015
|
+
function getMotionLevel() {
|
|
8016
|
+
return getMotionSensitivity() === 'minimal' || getMotionSensitivity() === 'static' ? 'off' : getMotionIntensity();
|
|
8017
|
+
}
|
|
8018
|
+
/** Re-apply a persisted level (call early on page load). Returns the active intensity. */
|
|
7968
8019
|
function restoreMotionIntensity() {
|
|
7969
8020
|
try {
|
|
7970
8021
|
const v = localStorage.getItem(KEY$1);
|
|
7971
8022
|
if (v && LEVELS.includes(v))
|
|
7972
|
-
|
|
8023
|
+
setMotionLevel(v);
|
|
7973
8024
|
}
|
|
7974
8025
|
catch {
|
|
7975
8026
|
/* ignore */
|
|
@@ -7979,10 +8030,10 @@ function restoreMotionIntensity() {
|
|
|
7979
8030
|
function defineMotionSwitch(tag = 'usa-motion-switch') {
|
|
7980
8031
|
return defineElement(tag, (Base) => class UsaMotionSwitch extends Base {
|
|
7981
8032
|
get value() {
|
|
7982
|
-
return
|
|
8033
|
+
return getMotionLevel();
|
|
7983
8034
|
}
|
|
7984
8035
|
set value(v) {
|
|
7985
|
-
|
|
8036
|
+
setMotionLevel(v, true);
|
|
7986
8037
|
this.sync();
|
|
7987
8038
|
}
|
|
7988
8039
|
mount() {
|
|
@@ -8173,7 +8224,7 @@ function defineTimeline(tag = 'usa-timeline') {
|
|
|
8173
8224
|
// (0–0.95) or `scrub="js"` opt into the JS engine, `scrub="scroll"`
|
|
8174
8225
|
// follows this element's own scroll position.
|
|
8175
8226
|
const v = this.str('scrub');
|
|
8176
|
-
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine:
|
|
8227
|
+
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: 'auto', source: v === 'scroll' ? 'scroll' : 'view' });
|
|
8177
8228
|
this.toggleAttribute('data-native', stop.native);
|
|
8178
8229
|
this.onCleanup(stop);
|
|
8179
8230
|
return;
|
|
@@ -8970,7 +9021,7 @@ function supportsWebGL() {
|
|
|
8970
9021
|
return support;
|
|
8971
9022
|
try {
|
|
8972
9023
|
const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;
|
|
8973
|
-
support = !!(c && (c.getContext('webgl')
|
|
9024
|
+
support = !!(c && (c.getContext('webgl')));
|
|
8974
9025
|
}
|
|
8975
9026
|
catch {
|
|
8976
9027
|
support = false;
|
|
@@ -8981,7 +9032,7 @@ function supportsWebGL() {
|
|
|
8981
9032
|
function glQuad(canvas, frag) {
|
|
8982
9033
|
let gl = null;
|
|
8983
9034
|
try {
|
|
8984
|
-
gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false })
|
|
9035
|
+
gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false }));
|
|
8985
9036
|
}
|
|
8986
9037
|
catch {
|
|
8987
9038
|
gl = null;
|
|
@@ -10039,6 +10090,304 @@ function definePacksComponents() {
|
|
|
10039
10090
|
definePack();
|
|
10040
10091
|
}
|
|
10041
10092
|
|
|
10093
|
+
/**
|
|
10094
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
10095
|
+
* yours) is a plain object registered once and played the same way:
|
|
10096
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
10097
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
10098
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
10099
|
+
* animation budget.
|
|
10100
|
+
*/
|
|
10101
|
+
const EFFECT_KINDS = ['enter', 'exit', 'attention', 'click', 'hover', 'card', 'loop', 'page', 'background', 'text', 'cursor', 'scroll'];
|
|
10102
|
+
const EFFECT_TRIGGERS = ['click', 'hover', 'enter', 'load', 'loop', 'manual'];
|
|
10103
|
+
const registry = new Map();
|
|
10104
|
+
/** Register an effect (throws on a duplicate name unless `override`). Returns an unregister function. */
|
|
10105
|
+
function registerEffect(def, opts = {}) {
|
|
10106
|
+
if (!/^[a-z][a-z0-9-]*$/.test(def.name))
|
|
10107
|
+
throw new Error(`[use-scroll-animate] invalid effect name "${def.name}"`);
|
|
10108
|
+
if (!EFFECT_KINDS.includes(def.kind))
|
|
10109
|
+
throw new Error(`[use-scroll-animate] unknown effect kind "${def.kind}"`);
|
|
10110
|
+
if (registry.has(def.name) && !opts.override)
|
|
10111
|
+
throw new Error(`[use-scroll-animate] effect "${def.name}" is already registered`);
|
|
10112
|
+
registry.set(def.name, def);
|
|
10113
|
+
return () => {
|
|
10114
|
+
if (registry.get(def.name) === def)
|
|
10115
|
+
registry.delete(def.name);
|
|
10116
|
+
};
|
|
10117
|
+
}
|
|
10118
|
+
/** Register several effects at once (already-registered names are skipped). */
|
|
10119
|
+
function registerEffects(defs) {
|
|
10120
|
+
for (const d of defs)
|
|
10121
|
+
if (!registry.has(d.name))
|
|
10122
|
+
registerEffect(d);
|
|
10123
|
+
}
|
|
10124
|
+
const getEffect = (name) => registry.get(name);
|
|
10125
|
+
const hasEffect = (name) => registry.has(name);
|
|
10126
|
+
/** Registered effects (optionally of one kind), sorted by name. */
|
|
10127
|
+
function listEffects(kind) {
|
|
10128
|
+
return Array.from(registry.values())
|
|
10129
|
+
.filter((d) => !kind || d.kind === kind)
|
|
10130
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
10131
|
+
}
|
|
10132
|
+
const SKIP_BY_DEFAULT = ['loop', 'background', 'cursor'];
|
|
10133
|
+
function context(event) {
|
|
10134
|
+
const cleanups = [];
|
|
10135
|
+
return {
|
|
10136
|
+
reduced: prefersReducedMotion(),
|
|
10137
|
+
sensitivity: getMotionSensitivity(),
|
|
10138
|
+
event,
|
|
10139
|
+
animate: animateWithMotion,
|
|
10140
|
+
onCleanup: (fn) => cleanups.push(fn),
|
|
10141
|
+
cleanups,
|
|
10142
|
+
};
|
|
10143
|
+
}
|
|
10144
|
+
/**
|
|
10145
|
+
* Play a registered effect once on `el`. Resolves when it finishes (or
|
|
10146
|
+
* immediately for fire-and-forget effects). Unknown names reject.
|
|
10147
|
+
*/
|
|
10148
|
+
async function playEffect(el, name, options = {}, event) {
|
|
10149
|
+
const def = registry.get(name);
|
|
10150
|
+
if (!def)
|
|
10151
|
+
throw new Error(`[use-scroll-animate] unknown effect "${name}" — registered: ${Array.from(registry.keys()).join(', ')}`);
|
|
10152
|
+
const ctx = context(event);
|
|
10153
|
+
if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip')
|
|
10154
|
+
return;
|
|
10155
|
+
const out = def.run(el, { ...(def.defaults || {}), ...options }, ctx);
|
|
10156
|
+
if (out && typeof out.finished?.then === 'function')
|
|
10157
|
+
await out.finished.catch(() => undefined);
|
|
10158
|
+
else if (out && typeof out.then === 'function')
|
|
10159
|
+
await out;
|
|
10160
|
+
}
|
|
10161
|
+
/**
|
|
10162
|
+
* Bind an effect to a trigger on `el`: `click`, `hover` (pointerenter / focus),
|
|
10163
|
+
* `enter` (scrolls into view; `once` by default), `load` (now), `loop`
|
|
10164
|
+
* (starts now, cleanup stops it) or `manual` (nothing). Returns an unbind.
|
|
10165
|
+
*/
|
|
10166
|
+
function bindEffect(el, name, options = {}) {
|
|
10167
|
+
const { trigger = 'click', once, ...opts } = options;
|
|
10168
|
+
const def = registry.get(name);
|
|
10169
|
+
if (!def)
|
|
10170
|
+
throw new Error(`[use-scroll-animate] unknown effect "${name}"`);
|
|
10171
|
+
const offs = [];
|
|
10172
|
+
const fire = (e) => {
|
|
10173
|
+
if (trigger === 'loop' || def.kind === 'loop' || def.kind === 'background' || def.kind === 'cursor') {
|
|
10174
|
+
const ctx = context(e);
|
|
10175
|
+
if (ctx.reduced && (def.reduced ?? 'skip') === 'skip')
|
|
10176
|
+
return;
|
|
10177
|
+
const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);
|
|
10178
|
+
if (typeof out === 'function')
|
|
10179
|
+
offs.push(out);
|
|
10180
|
+
offs.push(...ctx.cleanups);
|
|
10181
|
+
return;
|
|
10182
|
+
}
|
|
10183
|
+
void playEffect(el, name, opts, e).catch(() => undefined);
|
|
10184
|
+
};
|
|
10185
|
+
const on = (type, opt) => {
|
|
10186
|
+
el.addEventListener(type, fire, opt);
|
|
10187
|
+
offs.push(() => el.removeEventListener(type, fire, opt));
|
|
10188
|
+
};
|
|
10189
|
+
if (trigger === 'click')
|
|
10190
|
+
on('click', { once: !!once });
|
|
10191
|
+
else if (trigger === 'hover')
|
|
10192
|
+
(on('pointerenter'), on('focusin'));
|
|
10193
|
+
else if (trigger === 'load' || trigger === 'loop')
|
|
10194
|
+
fire();
|
|
10195
|
+
else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {
|
|
10196
|
+
const io = new IntersectionObserver((entries) => {
|
|
10197
|
+
for (const en of entries)
|
|
10198
|
+
if (en.isIntersecting) {
|
|
10199
|
+
fire();
|
|
10200
|
+
if (once !== false)
|
|
10201
|
+
io.disconnect();
|
|
10202
|
+
}
|
|
10203
|
+
}, { threshold: 0.15 });
|
|
10204
|
+
io.observe(el);
|
|
10205
|
+
offs.push(() => io.disconnect());
|
|
10206
|
+
}
|
|
10207
|
+
return () => offs.splice(0).reverse().forEach((f) => f());
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10210
|
+
function defineFx(tag = 'usa-fx') {
|
|
10211
|
+
return defineElement(tag, (Base) => class UsaFx extends Base {
|
|
10212
|
+
static get observedAttributes() {
|
|
10213
|
+
return ['effect', 'trigger', 'options'];
|
|
10214
|
+
}
|
|
10215
|
+
get target() {
|
|
10216
|
+
return this.flag('self') ? this : (this.firstElementChild || this);
|
|
10217
|
+
}
|
|
10218
|
+
opts() {
|
|
10219
|
+
try {
|
|
10220
|
+
return JSON.parse(this.str('options', '{}')) || {};
|
|
10221
|
+
}
|
|
10222
|
+
catch {
|
|
10223
|
+
return {};
|
|
10224
|
+
}
|
|
10225
|
+
}
|
|
10226
|
+
play() {
|
|
10227
|
+
return playEffect(this.target, this.str('effect', 'pop'), this.opts()).catch(() => undefined);
|
|
10228
|
+
}
|
|
10229
|
+
mount() {
|
|
10230
|
+
if (!this.style.display)
|
|
10231
|
+
this.style.display = 'inline-block';
|
|
10232
|
+
const name = this.str('effect', 'pop');
|
|
10233
|
+
const t = this.str('trigger', 'click');
|
|
10234
|
+
try {
|
|
10235
|
+
this.onCleanup(bindEffect(this.target, name, { ...this.opts(), trigger: EFFECT_TRIGGERS.includes(t) ? t : 'click', once: this.flag('once') }));
|
|
10236
|
+
this.removeAttribute('data-unknown');
|
|
10237
|
+
}
|
|
10238
|
+
catch {
|
|
10239
|
+
this.setAttribute('data-unknown', name); // not registered (yet)
|
|
10240
|
+
}
|
|
10241
|
+
}
|
|
10242
|
+
});
|
|
10243
|
+
}
|
|
10244
|
+
|
|
10245
|
+
/**
|
|
10246
|
+
* 5.0 built-in effects, all registered through `registerEffect()`:
|
|
10247
|
+
* every timeline preset as an `enter` effect, attention seekers, and the
|
|
10248
|
+
* click effects (burst, confetti, shake, ripple).
|
|
10249
|
+
*/
|
|
10250
|
+
const enter = Object.entries(TIMELINE_PRESETS).map(([name, frames]) => ({
|
|
10251
|
+
name,
|
|
10252
|
+
kind: 'enter',
|
|
10253
|
+
description: `Entrance: ${name} (same keyframes as the timeline preset).`,
|
|
10254
|
+
defaults: { duration: 600, delay: 0, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },
|
|
10255
|
+
run: (el, o, ctx) => ctx.animate(el, ctx.reduced ? [{ opacity: 0 }, { opacity: 1 }] : frames, { duration: o.duration, delay: o.delay, easing: o.easing, fill: 'backwards' }),
|
|
10256
|
+
}));
|
|
10257
|
+
const A = (name, description, frames, duration = 700, easing = 'ease-in-out') => ({
|
|
10258
|
+
name,
|
|
10259
|
+
kind: 'attention',
|
|
10260
|
+
description,
|
|
10261
|
+
defaults: { duration, iterations: 1 },
|
|
10262
|
+
run: (el, o, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.6 }, { opacity: 1 }], { duration: 400 }) : ctx.animate(el, frames, { duration: o.duration, easing, iterations: o.iterations })),
|
|
10263
|
+
});
|
|
10264
|
+
const attention = [
|
|
10265
|
+
A('pulse', 'Gentle scale pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.08)' }, { transform: 'scale(1)' }], 600),
|
|
10266
|
+
A('pop', 'Quick overshoot pop.', [{ transform: 'scale(1)' }, { transform: 'scale(1.18)', offset: 0.4 }, { transform: 'scale(0.96)', offset: 0.7 }, { transform: 'scale(1)' }], 450, 'cubic-bezier(0.34, 1.56, 0.64, 1)'),
|
|
10267
|
+
A('jelly', 'Rubbery squash-and-stretch.', [{ transform: 'scale(1,1)' }, { transform: 'scale(1.25,0.75)', offset: 0.3 }, { transform: 'scale(0.75,1.25)', offset: 0.4 }, { transform: 'scale(1.15,0.85)', offset: 0.5 }, { transform: 'scale(0.95,1.05)', offset: 0.65 }, { transform: 'scale(1.05,0.95)', offset: 0.75 }, { transform: 'scale(1,1)' }], 900),
|
|
10268
|
+
A('wiggle', 'Playful rotate wiggle.', [{ transform: 'rotate(0)' }, { transform: 'rotate(-8deg)', offset: 0.2 }, { transform: 'rotate(7deg)', offset: 0.4 }, { transform: 'rotate(-5deg)', offset: 0.6 }, { transform: 'rotate(3deg)', offset: 0.8 }, { transform: 'rotate(0)' }], 650),
|
|
10269
|
+
A('heartbeat', 'Double-beat heart pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.2)', offset: 0.14 }, { transform: 'scale(1)', offset: 0.28 }, { transform: 'scale(1.2)', offset: 0.42 }, { transform: 'scale(1)', offset: 0.7 }], 1100),
|
|
10270
|
+
A('bounce', 'Hop up and settle with a squash.', [{ transform: 'translateY(0) scale(1,1)' }, { transform: 'translateY(-22px) scale(0.95,1.05)', offset: 0.35 }, { transform: 'translateY(0) scale(1.08,0.92)', offset: 0.6 }, { transform: 'translateY(-6px) scale(1,1)', offset: 0.8 }, { transform: 'translateY(0) scale(1,1)' }], 800),
|
|
10271
|
+
A('flash', 'Two soft flashes (well under 3 per second).', [{ opacity: 1 }, { opacity: 0.25, offset: 0.25 }, { opacity: 1, offset: 0.5 }, { opacity: 0.25, offset: 0.75 }, { opacity: 1 }], 1400),
|
|
10272
|
+
A('tada', 'Scale + shake celebration.', [{ transform: 'scale(1) rotate(0)' }, { transform: 'scale(0.9) rotate(-3deg)', offset: 0.1 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.3 }, { transform: 'scale(1.1) rotate(-3deg)', offset: 0.5 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.7 }, { transform: 'scale(1) rotate(0)' }], 1000),
|
|
10273
|
+
];
|
|
10274
|
+
const click = [
|
|
10275
|
+
{
|
|
10276
|
+
name: 'burst',
|
|
10277
|
+
kind: 'click',
|
|
10278
|
+
description: 'Particle burst from the click point (or the element center).',
|
|
10279
|
+
defaults: { count: 12 },
|
|
10280
|
+
run: (el, o, ctx) => {
|
|
10281
|
+
if (ctx.reduced)
|
|
10282
|
+
return;
|
|
10283
|
+
const r = el.getBoundingClientRect();
|
|
10284
|
+
const e = ctx.event;
|
|
10285
|
+
burst(e?.clientX ?? r.left + r.width / 2, e?.clientY ?? r.top + r.height / 2, o);
|
|
10286
|
+
},
|
|
10287
|
+
},
|
|
10288
|
+
{
|
|
10289
|
+
name: 'confetti',
|
|
10290
|
+
kind: 'click',
|
|
10291
|
+
description: 'Confetti cannon from the element.',
|
|
10292
|
+
defaults: { count: 80 },
|
|
10293
|
+
run: (el, o, ctx) => {
|
|
10294
|
+
if (ctx.reduced)
|
|
10295
|
+
return;
|
|
10296
|
+
const r = el.getBoundingClientRect();
|
|
10297
|
+
confetti({ x: r.left + r.width / 2, y: r.top + r.height / 2, ...o });
|
|
10298
|
+
},
|
|
10299
|
+
},
|
|
10300
|
+
{
|
|
10301
|
+
name: 'shake',
|
|
10302
|
+
kind: 'attention',
|
|
10303
|
+
description: 'Horizontal "no" shake (errors, wrong password).',
|
|
10304
|
+
defaults: { intensity: 8, duration: 480 },
|
|
10305
|
+
run: (el, o, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.5 }, { opacity: 1 }], { duration: 300 }) : shake(el, o.intensity, o.duration)),
|
|
10306
|
+
},
|
|
10307
|
+
{
|
|
10308
|
+
name: 'ripple',
|
|
10309
|
+
kind: 'click',
|
|
10310
|
+
description: 'Material-style ink ripple from the pointer.',
|
|
10311
|
+
defaults: { color: 'currentColor', duration: 600 },
|
|
10312
|
+
run: (el, o, ctx) => {
|
|
10313
|
+
var _a;
|
|
10314
|
+
if (ctx.reduced)
|
|
10315
|
+
return;
|
|
10316
|
+
const r = el.getBoundingClientRect();
|
|
10317
|
+
const e = ctx.event;
|
|
10318
|
+
const d = Math.hypot(r.width, r.height) * 2;
|
|
10319
|
+
const dot = document.createElement('span');
|
|
10320
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
10321
|
+
Object.assign(dot.style, { position: 'absolute', left: `${(e?.clientX ?? r.left + r.width / 2) - r.left - d / 2}px`, top: `${(e?.clientY ?? r.top + r.height / 2) - r.top - d / 2}px`, width: `${d}px`, height: `${d}px`, borderRadius: '50%', background: o.color, opacity: '0.25', pointerEvents: 'none' });
|
|
10322
|
+
if (getComputedStyle(el).position === 'static')
|
|
10323
|
+
el.style.position = 'relative';
|
|
10324
|
+
(_a = el.style).overflow || (_a.overflow = 'hidden');
|
|
10325
|
+
el.appendChild(dot);
|
|
10326
|
+
const a = ctx.animate(dot, [{ transform: 'scale(0)', opacity: 0.3 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, easing: 'ease-out' });
|
|
10327
|
+
const done = () => dot.remove();
|
|
10328
|
+
if (a)
|
|
10329
|
+
a.finished.then(done, done);
|
|
10330
|
+
else
|
|
10331
|
+
done();
|
|
10332
|
+
return a;
|
|
10333
|
+
},
|
|
10334
|
+
},
|
|
10335
|
+
];
|
|
10336
|
+
/** Every built-in 5.0 effect definition. */
|
|
10337
|
+
const BUILTIN_EFFECTS = [...enter, ...attention, ...click];
|
|
10338
|
+
|
|
10339
|
+
/**
|
|
10340
|
+
* use-scroll-animate/components/fx — unified plugin-style effects (5.0).
|
|
10341
|
+
* `registerEffect({ name, kind, run })`, `playEffect(el, name)`,
|
|
10342
|
+
* `bindEffect(el, name, { trigger })`, `<usa-fx effect trigger>`. Built-ins:
|
|
10343
|
+
* every timeline preset (`enter`), `pulse` · `pop` · `jelly` · `wiggle` ·
|
|
10344
|
+
* `heartbeat` · `bounce` · `flash` · `tada` · `shake` (attention),
|
|
10345
|
+
* `burst` · `confetti` · `ripple` (click). More packs: `use-scroll-animate/components/effects`.
|
|
10346
|
+
*/
|
|
10347
|
+
/** Register the built-in effects (idempotent; `defineFxComponents()` calls it). */
|
|
10348
|
+
function registerBuiltinEffects() {
|
|
10349
|
+
registerEffects(BUILTIN_EFFECTS);
|
|
10350
|
+
}
|
|
10351
|
+
/** Register every component of this category under its default tag (+ the built-in effects). */
|
|
10352
|
+
function defineFxComponents() {
|
|
10353
|
+
registerBuiltinEffects();
|
|
10354
|
+
defineFx();
|
|
10355
|
+
}
|
|
10356
|
+
|
|
10357
|
+
/**
|
|
10358
|
+
* 4.9 — the 5.0 modern-browser baseline. `baselineReport()` lists which
|
|
10359
|
+
* required / progressive features this browser has; `warnBaseline()` logs
|
|
10360
|
+
* once in development when a required one is missing.
|
|
10361
|
+
*/
|
|
10362
|
+
/** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
|
|
10363
|
+
function baselineReport() {
|
|
10364
|
+
const w = (typeof window !== 'undefined' ? window : {});
|
|
10365
|
+
const d = (typeof document !== 'undefined' ? document : {});
|
|
10366
|
+
const css = (q) => typeof w.CSS?.supports === 'function' && w.CSS.supports(q);
|
|
10367
|
+
return [
|
|
10368
|
+
{ id: 'custom-elements', required: true, supported: !!w.customElements },
|
|
10369
|
+
{ id: 'web-animations', required: true, supported: typeof w.Element?.prototype?.animate === 'function' },
|
|
10370
|
+
{ id: 'intersection-observer', required: true, supported: typeof w.IntersectionObserver === 'function' },
|
|
10371
|
+
{ id: 'resize-observer', required: true, supported: typeof w.ResizeObserver === 'function' },
|
|
10372
|
+
{ id: 'adopted-stylesheets', required: true, supported: 'adoptedStyleSheets' in d },
|
|
10373
|
+
{ id: 'view-transitions', required: false, supported: typeof d.startViewTransition === 'function' },
|
|
10374
|
+
{ id: 'scroll-driven-animations', required: false, supported: css('animation-timeline: view()') },
|
|
10375
|
+
{ id: 'webgl', required: false, supported: !!(d.createElement && (() => { try {
|
|
10376
|
+
return d.createElement('canvas').getContext('webgl');
|
|
10377
|
+
}
|
|
10378
|
+
catch {
|
|
10379
|
+
return null;
|
|
10380
|
+
} })()) },
|
|
10381
|
+
];
|
|
10382
|
+
}
|
|
10383
|
+
/** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
|
|
10384
|
+
function warnBaseline() {
|
|
10385
|
+
const missing = baselineReport().filter((f) => f.required && !f.supported).map((f) => f.id);
|
|
10386
|
+
if (missing.length)
|
|
10387
|
+
deprecate('baseline', `this browser lacks ${missing.join(', ')}; use-scroll-animate 5.0 requires them (modern-browser baseline, see docs/upgrading-5.md).`);
|
|
10388
|
+
return missing;
|
|
10389
|
+
}
|
|
10390
|
+
|
|
10042
10391
|
/**
|
|
10043
10392
|
* use-scroll-animate/components/a11y — accessibility toolkit (4.4).
|
|
10044
10393
|
*
|
|
@@ -10129,6 +10478,7 @@ const STATIC_ALTERNATIVES = {
|
|
|
10129
10478
|
depth: 'Flat, front-facing layout.',
|
|
10130
10479
|
layout: 'Items reflow instantly.',
|
|
10131
10480
|
packs: 'Roles are styled but not animated.',
|
|
10481
|
+
fx: 'Effects are skipped or reduced to a short fade; the content is unchanged.',
|
|
10132
10482
|
};
|
|
10133
10483
|
/**
|
|
10134
10484
|
* Freeze a subtree at its static alternative: finishes running animations
|
|
@@ -10439,6 +10789,7 @@ const BY_CATEGORY = {
|
|
|
10439
10789
|
depth: defineDepthComponents,
|
|
10440
10790
|
layout: defineLayoutComponents,
|
|
10441
10791
|
packs: definePacksComponents,
|
|
10792
|
+
fx: defineFxComponents,
|
|
10442
10793
|
};
|
|
10443
10794
|
/**
|
|
10444
10795
|
* Register every `<usa-*>` component (or only the given categories).
|
|
@@ -10466,5 +10817,5 @@ function defineComponents(categories) {
|
|
|
10466
10817
|
const STYLE_BASE = new URL('../', import.meta.url).href;
|
|
10467
10818
|
onDemandStyles(STYLE_BASE);
|
|
10468
10819
|
|
|
10469
|
-
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BRIDGE_PROTOCOL_VERSION, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, GL_FALLBACKS, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, PARTICLE_PRESETS, POST_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, STYLE_BASE, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animationBudget, announce, applyMotionTokens, applyNativeSettings, applyPack, auditMotionA11y, autoAnimate, autoDegrade, burst, categoryOf, confetti, configureComponents, connectNativeShell, countUp, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoAnimate, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCube, defineCursor, defineDepth, defineDepthComponents, defineDialog, defineDistort, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLayoutComponents, defineLike, defineLiquid, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMasonry, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePack, definePacksComponents, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePostFx, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShader, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, defineWebglComponents, detectNativeHost, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getMotionIntensity, getMotionSensitivity, getMotionTokens, glFallbackCss, glGovernor, glQuad, graphemes, haptic, importMotionTokens, interpolatePath, linearEasing, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, parseNativeSettings, pathsCompatible, pinchScale, postFxShader, postToNative, prefersReducedMotion, projectInertia, readScrollProgress, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionSensitivity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, staticAlternative, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition, watchPowerSaver };
|
|
10820
|
+
export { ALL_TAGS, AMBIENT_EFFECTS, ANIM_ICONS, BRIDGE_PROTOCOL_VERSION, BUILTIN_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, EFFECT_KINDS, EFFECT_TRIGGERS, GL_FALLBACKS, JOINING_SCRIPT, LIVE_REGION_IDS, MASK_SHAPES, MORPH_ICONS, MOTION_SCALE, MOTION_SENSITIVITY, MOTION_SENSITIVITY_LEVELS, MOTION_TOKENS, PACKS, PACK_PRIMITIVES, PAGE_EFFECTS, PARTICLE_PRESETS, POST_EFFECTS, REVEAL_EFFECTS, SENSITIVITY_CSS, SHADERS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, STATIC_ALTERNATIVES, STYLE_BASE, TIMELINE_PRESETS, VARIANTS, activeAnimations, adaptKeyframes, adoptVariants, animateWithMotion, animationBudget, announce, applyMotionTokens, applyNativeSettings, applyPack, auditMotionA11y, autoAnimate, autoDegrade, baselineReport, bindEffect, burst, categoryOf, confetti, configureComponents, connectNativeShell, countUp, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAnimIcon, defineAurora, defineAutoAnimate, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCube, defineCursor, defineDepth, defineDepthComponents, defineDialog, defineDistort, defineDotNetwork, defineDoubleTap, defineDraggable, defineDraw, defineDrawer, defineFab, defineFeedbackComponents, defineFullpage, defineFx, defineFxComponents, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLayoutComponents, defineLike, defineLiquid, defineLoadingBar, defineMagnetic, defineMarquee, defineMaskReveal, defineMasonry, defineMorph, defineMotionSwitch, defineNavbar, defineOverscroll, definePack, definePacksComponents, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePostFx, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShader, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSvgComponents, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, defineWebglComponents, detectNativeHost, deviceTilt, drawLines, easeOutExpo, enableMpaTransitions, flip, flipFrames, fluentPreset, flyToCart, fragmentSource, gesture, getEffect, getMotionIntensity, getMotionLevel, getMotionSensitivity, getMotionTokens, glFallbackCss, glGovernor, glQuad, graphemes, haptic, hasEffect, importMotionTokens, interpolatePath, linearEasing, listEffects, liveRegion, loadCategoryStyles, loadedStyles, loadingBar, masonryLayout, mergeMotionTokens, morphPath, morphTo, motionAllowed, motionScale, motionToken, motionTokensToCss, motionTokensToJSON, motionTokensToVars, motionVar, onDemandStyles, onFrame, orientationToTilt, pageTransition, parseDuration, parseEasing, parseNativeSettings, pathsCompatible, pinchScale, playEffect, postFxShader, postToNative, prefersReducedMotion, projectInertia, readScrollProgress, registerBuiltinEffects, registerEffect, registerEffects, requestOrientationPermission, resolveDurationToken, resolveEasingToken, resolvePosition, resolveSpring, restoreMotionIntensity, restoreMotionSensitivity, revealKeyframes, rubberBand, schedulerStats, scrambleFrame, scrollToTarget, setAnimationBudget, setMotionIntensity, setMotionLevel, setMotionSensitivity, setVariant, shake, sharedTransition, smoothScroll, snapTo, splitOrder, splitText, splitTimeline, words as splitWords, spring, springEasing, springEffectKeyframes, springSamples, staticAlternative, stepSpring, supportsLinearEasing, supportsNativeScrub, supportsOrientation, supportsViewTransitions, supportsWebGL, swipeDirection, themeTransition, timeline, toast, viewTransition, warnBaseline, watchPowerSaver, withoutDeprecations };
|
|
10470
10821
|
//# sourceMappingURL=lite.js.map
|