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.cjs
CHANGED
|
@@ -10,10 +10,16 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
|
|
|
10
10
|
* scripts. Classes are created the first time a `define*()` function runs.
|
|
11
11
|
*/
|
|
12
12
|
const MOTION_SENSITIVITY_LEVELS = ['full', 'gentle', 'minimal', 'static'];
|
|
13
|
-
const MOTION_SCALE = {
|
|
13
|
+
const MOTION_SCALE = { low: 0.6, normal: 1, high: 1.25 };
|
|
14
14
|
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };
|
|
15
15
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
16
16
|
function configureComponents(options) {
|
|
17
|
+
options = { ...options };
|
|
18
|
+
// 5.0: removed values are ignored (see docs/upgrading-5.md)
|
|
19
|
+
if (options.motionIntensity && !(options.motionIntensity in MOTION_SCALE))
|
|
20
|
+
delete options.motionIntensity;
|
|
21
|
+
if (options.reducedMotion && options.reducedMotion !== 'reduce')
|
|
22
|
+
options.reducedMotion = 'user';
|
|
17
23
|
Object.assign(config, options);
|
|
18
24
|
if (options.motionIntensity && typeof document !== 'undefined') {
|
|
19
25
|
document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
|
|
@@ -58,6 +64,14 @@ function adaptKeyframes(frames, level = config.motionSensitivity) {
|
|
|
58
64
|
return out;
|
|
59
65
|
});
|
|
60
66
|
}
|
|
67
|
+
/** Run `fn` without 4.9 deprecation warnings (library-internal calls). */
|
|
68
|
+
function withoutDeprecations(fn) {
|
|
69
|
+
try {
|
|
70
|
+
return fn();
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
61
75
|
/** The current global motion intensity. */
|
|
62
76
|
function getMotionIntensity() {
|
|
63
77
|
return config.motionIntensity;
|
|
@@ -69,10 +83,10 @@ function motionScale() {
|
|
|
69
83
|
const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
|
|
70
84
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
71
85
|
function prefersReducedMotion() {
|
|
72
|
-
if (config.
|
|
86
|
+
if (config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static')
|
|
87
|
+
return true;
|
|
88
|
+
if (config.reducedMotion === 'reduce')
|
|
73
89
|
return true;
|
|
74
|
-
if (config.reducedMotion !== 'user')
|
|
75
|
-
return config.reducedMotion === 'reduce';
|
|
76
90
|
return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
77
91
|
}
|
|
78
92
|
const injected = new Set();
|
|
@@ -208,31 +222,7 @@ function getBase() {
|
|
|
208
222
|
}
|
|
209
223
|
/** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */
|
|
210
224
|
motion(el, keyframes, options) {
|
|
211
|
-
|
|
212
|
-
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
keyframes = adaptKeyframes(keyframes);
|
|
216
|
-
if (active$1 >= maxActive) {
|
|
217
|
-
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
const k = motionScale();
|
|
221
|
-
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
222
|
-
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
223
|
-
const a = el.animate(keyframes, options);
|
|
224
|
-
if (options.iterations !== Infinity) {
|
|
225
|
-
active$1++;
|
|
226
|
-
let done = false;
|
|
227
|
-
const end = () => {
|
|
228
|
-
if (!done) {
|
|
229
|
-
done = true;
|
|
230
|
-
active$1--;
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
a?.finished?.then(end, end);
|
|
234
|
-
}
|
|
235
|
-
return a;
|
|
225
|
+
return animateWithMotion(el, keyframes, options);
|
|
236
226
|
}
|
|
237
227
|
emit(type, detail) {
|
|
238
228
|
return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
|
|
@@ -241,6 +231,39 @@ function getBase() {
|
|
|
241
231
|
baseClass = Base;
|
|
242
232
|
return baseClass;
|
|
243
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* `el.animate()` with the library's motion rules (5.0, shared by elements and
|
|
236
|
+
* registered effects): motion sensitivity (keyframes adapted, `static` →
|
|
237
|
+
* final frame), intensity (duration scale) and the animation budget. Returns
|
|
238
|
+
* `null` (final frame applied) when nothing should animate.
|
|
239
|
+
*/
|
|
240
|
+
function animateWithMotion(el, keyframes, options) {
|
|
241
|
+
if (typeof el.animate !== 'function' || config.motionSensitivity === 'static') {
|
|
242
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
keyframes = adaptKeyframes(keyframes);
|
|
246
|
+
if (active$1 >= maxActive) {
|
|
247
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
const k = motionScale();
|
|
251
|
+
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
252
|
+
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
253
|
+
const a = el.animate(keyframes, options);
|
|
254
|
+
if (options.iterations !== Infinity) {
|
|
255
|
+
active$1++;
|
|
256
|
+
let done = false;
|
|
257
|
+
const end = () => {
|
|
258
|
+
if (!done) {
|
|
259
|
+
done = true;
|
|
260
|
+
active$1--;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
a?.finished?.then(end, end);
|
|
264
|
+
}
|
|
265
|
+
return a;
|
|
266
|
+
}
|
|
244
267
|
/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */
|
|
245
268
|
function applyFrame(el, frame) {
|
|
246
269
|
if (!frame)
|
|
@@ -361,6 +384,15 @@ const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
|
361
384
|
const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
|
|
362
385
|
/** Windows Fluent "decelerate" / "point-to-point" curves. */
|
|
363
386
|
const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';
|
|
387
|
+
const warned = new Set();
|
|
388
|
+
/** Log a deprecation once per key (console.warn). */
|
|
389
|
+
function deprecate(key, message) {
|
|
390
|
+
if (warned.has(key))
|
|
391
|
+
return;
|
|
392
|
+
warned.add(key);
|
|
393
|
+
if (typeof console !== 'undefined')
|
|
394
|
+
console.warn(`[use-scroll-animate] ${message}`);
|
|
395
|
+
}
|
|
364
396
|
/**
|
|
365
397
|
* The `kind` attribute of `<usa-spinner>`, `<usa-check>`, `<usa-dialog>` and
|
|
366
398
|
* `<usa-acrylic>` (3.0: `variant` only selects a style variant).
|
|
@@ -392,6 +424,7 @@ const COMPONENT_CATEGORIES = {
|
|
|
392
424
|
depth: ['usa-cube', 'usa-depth'],
|
|
393
425
|
layout: ['usa-auto-animate', 'usa-masonry'],
|
|
394
426
|
packs: ['usa-pack'],
|
|
427
|
+
fx: ['usa-fx'],
|
|
395
428
|
};
|
|
396
429
|
|
|
397
430
|
/**
|
|
@@ -427,8 +460,7 @@ function autoDegrade(options = {}) {
|
|
|
427
460
|
state.reason = reason;
|
|
428
461
|
if (degraded) {
|
|
429
462
|
prev = { intensity: getMotionIntensity(), budget: animationBudget() };
|
|
430
|
-
|
|
431
|
-
configureComponents({ motionIntensity: 'low' });
|
|
463
|
+
configureComponents({ motionIntensity: 'low' });
|
|
432
464
|
setAnimationBudget(Math.max(4, Math.floor(maxActive / 2)));
|
|
433
465
|
}
|
|
434
466
|
else if (prev) {
|
|
@@ -7944,18 +7976,23 @@ function defineAutoSkeleton(tag = 'usa-auto-skeleton') {
|
|
|
7944
7976
|
|
|
7945
7977
|
var css$7 = "";
|
|
7946
7978
|
|
|
7979
|
+
const INTENSITIES = ['low', 'normal', 'high'];
|
|
7947
7980
|
const LEVELS = ['off', 'low', 'normal', 'high'];
|
|
7948
7981
|
const KEY$1 = 'usa:motion';
|
|
7949
7982
|
/**
|
|
7950
7983
|
* Set the global motion intensity for every `<usa-*>` component:
|
|
7951
|
-
* `'
|
|
7952
|
-
*
|
|
7953
|
-
*
|
|
7984
|
+
* `'low'`, `'normal'` (default), `'high'`. Sets `--usa-motion` and
|
|
7985
|
+
* `data-usa-motion` on `<html>`; with `persist` the choice is remembered
|
|
7986
|
+
* (localStorage) and restored by `restoreMotionIntensity()`.
|
|
7987
|
+
* 5.0: `'off'` was removed — use `setMotionSensitivity('minimal')`.
|
|
7954
7988
|
*/
|
|
7955
7989
|
function setMotionIntensity(level, persist = false) {
|
|
7956
|
-
if (!
|
|
7990
|
+
if (!INTENSITIES.includes(level))
|
|
7957
7991
|
return;
|
|
7958
7992
|
configureComponents({ motionIntensity: level });
|
|
7993
|
+
store(level, persist);
|
|
7994
|
+
}
|
|
7995
|
+
function store(level, persist) {
|
|
7959
7996
|
if (persist) {
|
|
7960
7997
|
try {
|
|
7961
7998
|
localStorage.setItem(KEY$1, level);
|
|
@@ -7967,12 +8004,26 @@ function setMotionIntensity(level, persist = false) {
|
|
|
7967
8004
|
if (typeof document !== 'undefined')
|
|
7968
8005
|
document.dispatchEvent(new CustomEvent('usa:motion', { detail: { level } }));
|
|
7969
8006
|
}
|
|
7970
|
-
/**
|
|
8007
|
+
/** Apply a switch level: `'off'` = motion sensitivity `minimal`, otherwise full motion at that intensity. */
|
|
8008
|
+
function setMotionLevel(level, persist = false) {
|
|
8009
|
+
if (!LEVELS.includes(level))
|
|
8010
|
+
return;
|
|
8011
|
+
if (level === 'off')
|
|
8012
|
+
configureComponents({ motionSensitivity: 'minimal' });
|
|
8013
|
+
else
|
|
8014
|
+
configureComponents({ motionIntensity: level, ...(getMotionSensitivity() === 'minimal' ? { motionSensitivity: 'full' } : {}) });
|
|
8015
|
+
store(level, persist);
|
|
8016
|
+
}
|
|
8017
|
+
/** The current switch level. */
|
|
8018
|
+
function getMotionLevel() {
|
|
8019
|
+
return getMotionSensitivity() === 'minimal' || getMotionSensitivity() === 'static' ? 'off' : getMotionIntensity();
|
|
8020
|
+
}
|
|
8021
|
+
/** Re-apply a persisted level (call early on page load). Returns the active intensity. */
|
|
7971
8022
|
function restoreMotionIntensity() {
|
|
7972
8023
|
try {
|
|
7973
8024
|
const v = localStorage.getItem(KEY$1);
|
|
7974
8025
|
if (v && LEVELS.includes(v))
|
|
7975
|
-
|
|
8026
|
+
setMotionLevel(v);
|
|
7976
8027
|
}
|
|
7977
8028
|
catch {
|
|
7978
8029
|
/* ignore */
|
|
@@ -7982,10 +8033,10 @@ function restoreMotionIntensity() {
|
|
|
7982
8033
|
function defineMotionSwitch(tag = 'usa-motion-switch') {
|
|
7983
8034
|
return defineElement(tag, (Base) => class UsaMotionSwitch extends Base {
|
|
7984
8035
|
get value() {
|
|
7985
|
-
return
|
|
8036
|
+
return getMotionLevel();
|
|
7986
8037
|
}
|
|
7987
8038
|
set value(v) {
|
|
7988
|
-
|
|
8039
|
+
setMotionLevel(v, true);
|
|
7989
8040
|
this.sync();
|
|
7990
8041
|
}
|
|
7991
8042
|
mount() {
|
|
@@ -8176,7 +8227,7 @@ function defineTimeline(tag = 'usa-timeline') {
|
|
|
8176
8227
|
// (0–0.95) or `scrub="js"` opt into the JS engine, `scrub="scroll"`
|
|
8177
8228
|
// follows this element's own scroll position.
|
|
8178
8229
|
const v = this.str('scrub');
|
|
8179
|
-
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine:
|
|
8230
|
+
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: 'auto', source: v === 'scroll' ? 'scroll' : 'view' });
|
|
8180
8231
|
this.toggleAttribute('data-native', stop.native);
|
|
8181
8232
|
this.onCleanup(stop);
|
|
8182
8233
|
return;
|
|
@@ -8973,7 +9024,7 @@ function supportsWebGL() {
|
|
|
8973
9024
|
return support;
|
|
8974
9025
|
try {
|
|
8975
9026
|
const c = typeof document !== 'undefined' ? document.createElement('canvas') : null;
|
|
8976
|
-
support = !!(c && (c.getContext('webgl')
|
|
9027
|
+
support = !!(c && (c.getContext('webgl')));
|
|
8977
9028
|
}
|
|
8978
9029
|
catch {
|
|
8979
9030
|
support = false;
|
|
@@ -8984,7 +9035,7 @@ function supportsWebGL() {
|
|
|
8984
9035
|
function glQuad(canvas, frag) {
|
|
8985
9036
|
let gl = null;
|
|
8986
9037
|
try {
|
|
8987
|
-
gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false })
|
|
9038
|
+
gl = (canvas.getContext('webgl', { premultipliedAlpha: false, antialias: false }));
|
|
8988
9039
|
}
|
|
8989
9040
|
catch {
|
|
8990
9041
|
gl = null;
|
|
@@ -10042,6 +10093,304 @@ function definePacksComponents() {
|
|
|
10042
10093
|
definePack();
|
|
10043
10094
|
}
|
|
10044
10095
|
|
|
10096
|
+
/**
|
|
10097
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
10098
|
+
* yours) is a plain object registered once and played the same way:
|
|
10099
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
10100
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
10101
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
10102
|
+
* animation budget.
|
|
10103
|
+
*/
|
|
10104
|
+
const EFFECT_KINDS = ['enter', 'exit', 'attention', 'click', 'hover', 'card', 'loop', 'page', 'background', 'text', 'cursor', 'scroll'];
|
|
10105
|
+
const EFFECT_TRIGGERS = ['click', 'hover', 'enter', 'load', 'loop', 'manual'];
|
|
10106
|
+
const registry = new Map();
|
|
10107
|
+
/** Register an effect (throws on a duplicate name unless `override`). Returns an unregister function. */
|
|
10108
|
+
function registerEffect(def, opts = {}) {
|
|
10109
|
+
if (!/^[a-z][a-z0-9-]*$/.test(def.name))
|
|
10110
|
+
throw new Error(`[use-scroll-animate] invalid effect name "${def.name}"`);
|
|
10111
|
+
if (!EFFECT_KINDS.includes(def.kind))
|
|
10112
|
+
throw new Error(`[use-scroll-animate] unknown effect kind "${def.kind}"`);
|
|
10113
|
+
if (registry.has(def.name) && !opts.override)
|
|
10114
|
+
throw new Error(`[use-scroll-animate] effect "${def.name}" is already registered`);
|
|
10115
|
+
registry.set(def.name, def);
|
|
10116
|
+
return () => {
|
|
10117
|
+
if (registry.get(def.name) === def)
|
|
10118
|
+
registry.delete(def.name);
|
|
10119
|
+
};
|
|
10120
|
+
}
|
|
10121
|
+
/** Register several effects at once (already-registered names are skipped). */
|
|
10122
|
+
function registerEffects(defs) {
|
|
10123
|
+
for (const d of defs)
|
|
10124
|
+
if (!registry.has(d.name))
|
|
10125
|
+
registerEffect(d);
|
|
10126
|
+
}
|
|
10127
|
+
const getEffect = (name) => registry.get(name);
|
|
10128
|
+
const hasEffect = (name) => registry.has(name);
|
|
10129
|
+
/** Registered effects (optionally of one kind), sorted by name. */
|
|
10130
|
+
function listEffects(kind) {
|
|
10131
|
+
return Array.from(registry.values())
|
|
10132
|
+
.filter((d) => !kind || d.kind === kind)
|
|
10133
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
10134
|
+
}
|
|
10135
|
+
const SKIP_BY_DEFAULT = ['loop', 'background', 'cursor'];
|
|
10136
|
+
function context(event) {
|
|
10137
|
+
const cleanups = [];
|
|
10138
|
+
return {
|
|
10139
|
+
reduced: prefersReducedMotion(),
|
|
10140
|
+
sensitivity: getMotionSensitivity(),
|
|
10141
|
+
event,
|
|
10142
|
+
animate: animateWithMotion,
|
|
10143
|
+
onCleanup: (fn) => cleanups.push(fn),
|
|
10144
|
+
cleanups,
|
|
10145
|
+
};
|
|
10146
|
+
}
|
|
10147
|
+
/**
|
|
10148
|
+
* Play a registered effect once on `el`. Resolves when it finishes (or
|
|
10149
|
+
* immediately for fire-and-forget effects). Unknown names reject.
|
|
10150
|
+
*/
|
|
10151
|
+
async function playEffect(el, name, options = {}, event) {
|
|
10152
|
+
const def = registry.get(name);
|
|
10153
|
+
if (!def)
|
|
10154
|
+
throw new Error(`[use-scroll-animate] unknown effect "${name}" — registered: ${Array.from(registry.keys()).join(', ')}`);
|
|
10155
|
+
const ctx = context(event);
|
|
10156
|
+
if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip')
|
|
10157
|
+
return;
|
|
10158
|
+
const out = def.run(el, { ...(def.defaults || {}), ...options }, ctx);
|
|
10159
|
+
if (out && typeof out.finished?.then === 'function')
|
|
10160
|
+
await out.finished.catch(() => undefined);
|
|
10161
|
+
else if (out && typeof out.then === 'function')
|
|
10162
|
+
await out;
|
|
10163
|
+
}
|
|
10164
|
+
/**
|
|
10165
|
+
* Bind an effect to a trigger on `el`: `click`, `hover` (pointerenter / focus),
|
|
10166
|
+
* `enter` (scrolls into view; `once` by default), `load` (now), `loop`
|
|
10167
|
+
* (starts now, cleanup stops it) or `manual` (nothing). Returns an unbind.
|
|
10168
|
+
*/
|
|
10169
|
+
function bindEffect(el, name, options = {}) {
|
|
10170
|
+
const { trigger = 'click', once, ...opts } = options;
|
|
10171
|
+
const def = registry.get(name);
|
|
10172
|
+
if (!def)
|
|
10173
|
+
throw new Error(`[use-scroll-animate] unknown effect "${name}"`);
|
|
10174
|
+
const offs = [];
|
|
10175
|
+
const fire = (e) => {
|
|
10176
|
+
if (trigger === 'loop' || def.kind === 'loop' || def.kind === 'background' || def.kind === 'cursor') {
|
|
10177
|
+
const ctx = context(e);
|
|
10178
|
+
if (ctx.reduced && (def.reduced ?? 'skip') === 'skip')
|
|
10179
|
+
return;
|
|
10180
|
+
const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);
|
|
10181
|
+
if (typeof out === 'function')
|
|
10182
|
+
offs.push(out);
|
|
10183
|
+
offs.push(...ctx.cleanups);
|
|
10184
|
+
return;
|
|
10185
|
+
}
|
|
10186
|
+
void playEffect(el, name, opts, e).catch(() => undefined);
|
|
10187
|
+
};
|
|
10188
|
+
const on = (type, opt) => {
|
|
10189
|
+
el.addEventListener(type, fire, opt);
|
|
10190
|
+
offs.push(() => el.removeEventListener(type, fire, opt));
|
|
10191
|
+
};
|
|
10192
|
+
if (trigger === 'click')
|
|
10193
|
+
on('click', { once: !!once });
|
|
10194
|
+
else if (trigger === 'hover')
|
|
10195
|
+
(on('pointerenter'), on('focusin'));
|
|
10196
|
+
else if (trigger === 'load' || trigger === 'loop')
|
|
10197
|
+
fire();
|
|
10198
|
+
else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {
|
|
10199
|
+
const io = new IntersectionObserver((entries) => {
|
|
10200
|
+
for (const en of entries)
|
|
10201
|
+
if (en.isIntersecting) {
|
|
10202
|
+
fire();
|
|
10203
|
+
if (once !== false)
|
|
10204
|
+
io.disconnect();
|
|
10205
|
+
}
|
|
10206
|
+
}, { threshold: 0.15 });
|
|
10207
|
+
io.observe(el);
|
|
10208
|
+
offs.push(() => io.disconnect());
|
|
10209
|
+
}
|
|
10210
|
+
return () => offs.splice(0).reverse().forEach((f) => f());
|
|
10211
|
+
}
|
|
10212
|
+
|
|
10213
|
+
function defineFx(tag = 'usa-fx') {
|
|
10214
|
+
return defineElement(tag, (Base) => class UsaFx extends Base {
|
|
10215
|
+
static get observedAttributes() {
|
|
10216
|
+
return ['effect', 'trigger', 'options'];
|
|
10217
|
+
}
|
|
10218
|
+
get target() {
|
|
10219
|
+
return this.flag('self') ? this : (this.firstElementChild || this);
|
|
10220
|
+
}
|
|
10221
|
+
opts() {
|
|
10222
|
+
try {
|
|
10223
|
+
return JSON.parse(this.str('options', '{}')) || {};
|
|
10224
|
+
}
|
|
10225
|
+
catch {
|
|
10226
|
+
return {};
|
|
10227
|
+
}
|
|
10228
|
+
}
|
|
10229
|
+
play() {
|
|
10230
|
+
return playEffect(this.target, this.str('effect', 'pop'), this.opts()).catch(() => undefined);
|
|
10231
|
+
}
|
|
10232
|
+
mount() {
|
|
10233
|
+
if (!this.style.display)
|
|
10234
|
+
this.style.display = 'inline-block';
|
|
10235
|
+
const name = this.str('effect', 'pop');
|
|
10236
|
+
const t = this.str('trigger', 'click');
|
|
10237
|
+
try {
|
|
10238
|
+
this.onCleanup(bindEffect(this.target, name, { ...this.opts(), trigger: EFFECT_TRIGGERS.includes(t) ? t : 'click', once: this.flag('once') }));
|
|
10239
|
+
this.removeAttribute('data-unknown');
|
|
10240
|
+
}
|
|
10241
|
+
catch {
|
|
10242
|
+
this.setAttribute('data-unknown', name); // not registered (yet)
|
|
10243
|
+
}
|
|
10244
|
+
}
|
|
10245
|
+
});
|
|
10246
|
+
}
|
|
10247
|
+
|
|
10248
|
+
/**
|
|
10249
|
+
* 5.0 built-in effects, all registered through `registerEffect()`:
|
|
10250
|
+
* every timeline preset as an `enter` effect, attention seekers, and the
|
|
10251
|
+
* click effects (burst, confetti, shake, ripple).
|
|
10252
|
+
*/
|
|
10253
|
+
const enter = Object.entries(TIMELINE_PRESETS).map(([name, frames]) => ({
|
|
10254
|
+
name,
|
|
10255
|
+
kind: 'enter',
|
|
10256
|
+
description: `Entrance: ${name} (same keyframes as the timeline preset).`,
|
|
10257
|
+
defaults: { duration: 600, delay: 0, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },
|
|
10258
|
+
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' }),
|
|
10259
|
+
}));
|
|
10260
|
+
const A = (name, description, frames, duration = 700, easing = 'ease-in-out') => ({
|
|
10261
|
+
name,
|
|
10262
|
+
kind: 'attention',
|
|
10263
|
+
description,
|
|
10264
|
+
defaults: { duration, iterations: 1 },
|
|
10265
|
+
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 })),
|
|
10266
|
+
});
|
|
10267
|
+
const attention = [
|
|
10268
|
+
A('pulse', 'Gentle scale pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.08)' }, { transform: 'scale(1)' }], 600),
|
|
10269
|
+
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)'),
|
|
10270
|
+
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),
|
|
10271
|
+
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),
|
|
10272
|
+
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),
|
|
10273
|
+
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),
|
|
10274
|
+
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),
|
|
10275
|
+
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),
|
|
10276
|
+
];
|
|
10277
|
+
const click = [
|
|
10278
|
+
{
|
|
10279
|
+
name: 'burst',
|
|
10280
|
+
kind: 'click',
|
|
10281
|
+
description: 'Particle burst from the click point (or the element center).',
|
|
10282
|
+
defaults: { count: 12 },
|
|
10283
|
+
run: (el, o, ctx) => {
|
|
10284
|
+
if (ctx.reduced)
|
|
10285
|
+
return;
|
|
10286
|
+
const r = el.getBoundingClientRect();
|
|
10287
|
+
const e = ctx.event;
|
|
10288
|
+
burst(e?.clientX ?? r.left + r.width / 2, e?.clientY ?? r.top + r.height / 2, o);
|
|
10289
|
+
},
|
|
10290
|
+
},
|
|
10291
|
+
{
|
|
10292
|
+
name: 'confetti',
|
|
10293
|
+
kind: 'click',
|
|
10294
|
+
description: 'Confetti cannon from the element.',
|
|
10295
|
+
defaults: { count: 80 },
|
|
10296
|
+
run: (el, o, ctx) => {
|
|
10297
|
+
if (ctx.reduced)
|
|
10298
|
+
return;
|
|
10299
|
+
const r = el.getBoundingClientRect();
|
|
10300
|
+
confetti({ x: r.left + r.width / 2, y: r.top + r.height / 2, ...o });
|
|
10301
|
+
},
|
|
10302
|
+
},
|
|
10303
|
+
{
|
|
10304
|
+
name: 'shake',
|
|
10305
|
+
kind: 'attention',
|
|
10306
|
+
description: 'Horizontal "no" shake (errors, wrong password).',
|
|
10307
|
+
defaults: { intensity: 8, duration: 480 },
|
|
10308
|
+
run: (el, o, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.5 }, { opacity: 1 }], { duration: 300 }) : shake(el, o.intensity, o.duration)),
|
|
10309
|
+
},
|
|
10310
|
+
{
|
|
10311
|
+
name: 'ripple',
|
|
10312
|
+
kind: 'click',
|
|
10313
|
+
description: 'Material-style ink ripple from the pointer.',
|
|
10314
|
+
defaults: { color: 'currentColor', duration: 600 },
|
|
10315
|
+
run: (el, o, ctx) => {
|
|
10316
|
+
var _a;
|
|
10317
|
+
if (ctx.reduced)
|
|
10318
|
+
return;
|
|
10319
|
+
const r = el.getBoundingClientRect();
|
|
10320
|
+
const e = ctx.event;
|
|
10321
|
+
const d = Math.hypot(r.width, r.height) * 2;
|
|
10322
|
+
const dot = document.createElement('span');
|
|
10323
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
10324
|
+
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' });
|
|
10325
|
+
if (getComputedStyle(el).position === 'static')
|
|
10326
|
+
el.style.position = 'relative';
|
|
10327
|
+
(_a = el.style).overflow || (_a.overflow = 'hidden');
|
|
10328
|
+
el.appendChild(dot);
|
|
10329
|
+
const a = ctx.animate(dot, [{ transform: 'scale(0)', opacity: 0.3 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, easing: 'ease-out' });
|
|
10330
|
+
const done = () => dot.remove();
|
|
10331
|
+
if (a)
|
|
10332
|
+
a.finished.then(done, done);
|
|
10333
|
+
else
|
|
10334
|
+
done();
|
|
10335
|
+
return a;
|
|
10336
|
+
},
|
|
10337
|
+
},
|
|
10338
|
+
];
|
|
10339
|
+
/** Every built-in 5.0 effect definition. */
|
|
10340
|
+
const BUILTIN_EFFECTS = [...enter, ...attention, ...click];
|
|
10341
|
+
|
|
10342
|
+
/**
|
|
10343
|
+
* use-scroll-animate/components/fx — unified plugin-style effects (5.0).
|
|
10344
|
+
* `registerEffect({ name, kind, run })`, `playEffect(el, name)`,
|
|
10345
|
+
* `bindEffect(el, name, { trigger })`, `<usa-fx effect trigger>`. Built-ins:
|
|
10346
|
+
* every timeline preset (`enter`), `pulse` · `pop` · `jelly` · `wiggle` ·
|
|
10347
|
+
* `heartbeat` · `bounce` · `flash` · `tada` · `shake` (attention),
|
|
10348
|
+
* `burst` · `confetti` · `ripple` (click). More packs: `use-scroll-animate/components/effects`.
|
|
10349
|
+
*/
|
|
10350
|
+
/** Register the built-in effects (idempotent; `defineFxComponents()` calls it). */
|
|
10351
|
+
function registerBuiltinEffects() {
|
|
10352
|
+
registerEffects(BUILTIN_EFFECTS);
|
|
10353
|
+
}
|
|
10354
|
+
/** Register every component of this category under its default tag (+ the built-in effects). */
|
|
10355
|
+
function defineFxComponents() {
|
|
10356
|
+
registerBuiltinEffects();
|
|
10357
|
+
defineFx();
|
|
10358
|
+
}
|
|
10359
|
+
|
|
10360
|
+
/**
|
|
10361
|
+
* 4.9 — the 5.0 modern-browser baseline. `baselineReport()` lists which
|
|
10362
|
+
* required / progressive features this browser has; `warnBaseline()` logs
|
|
10363
|
+
* once in development when a required one is missing.
|
|
10364
|
+
*/
|
|
10365
|
+
/** Required in 5.0: Custom Elements, WAAPI, IntersectionObserver, ResizeObserver, adoptedStyleSheets. Progressive: View Transitions, scroll-driven animations, WebGL. */
|
|
10366
|
+
function baselineReport() {
|
|
10367
|
+
const w = (typeof window !== 'undefined' ? window : {});
|
|
10368
|
+
const d = (typeof document !== 'undefined' ? document : {});
|
|
10369
|
+
const css = (q) => typeof w.CSS?.supports === 'function' && w.CSS.supports(q);
|
|
10370
|
+
return [
|
|
10371
|
+
{ id: 'custom-elements', required: true, supported: !!w.customElements },
|
|
10372
|
+
{ id: 'web-animations', required: true, supported: typeof w.Element?.prototype?.animate === 'function' },
|
|
10373
|
+
{ id: 'intersection-observer', required: true, supported: typeof w.IntersectionObserver === 'function' },
|
|
10374
|
+
{ id: 'resize-observer', required: true, supported: typeof w.ResizeObserver === 'function' },
|
|
10375
|
+
{ id: 'adopted-stylesheets', required: true, supported: 'adoptedStyleSheets' in d },
|
|
10376
|
+
{ id: 'view-transitions', required: false, supported: typeof d.startViewTransition === 'function' },
|
|
10377
|
+
{ id: 'scroll-driven-animations', required: false, supported: css('animation-timeline: view()') },
|
|
10378
|
+
{ id: 'webgl', required: false, supported: !!(d.createElement && (() => { try {
|
|
10379
|
+
return d.createElement('canvas').getContext('webgl');
|
|
10380
|
+
}
|
|
10381
|
+
catch {
|
|
10382
|
+
return null;
|
|
10383
|
+
} })()) },
|
|
10384
|
+
];
|
|
10385
|
+
}
|
|
10386
|
+
/** Log (once) which required 5.0 features are missing here. Returns the missing ids. */
|
|
10387
|
+
function warnBaseline() {
|
|
10388
|
+
const missing = baselineReport().filter((f) => f.required && !f.supported).map((f) => f.id);
|
|
10389
|
+
if (missing.length)
|
|
10390
|
+
deprecate('baseline', `this browser lacks ${missing.join(', ')}; use-scroll-animate 5.0 requires them (modern-browser baseline, see docs/upgrading-5.md).`);
|
|
10391
|
+
return missing;
|
|
10392
|
+
}
|
|
10393
|
+
|
|
10045
10394
|
/**
|
|
10046
10395
|
* use-scroll-animate/components/a11y — accessibility toolkit (4.4).
|
|
10047
10396
|
*
|
|
@@ -10132,6 +10481,7 @@ const STATIC_ALTERNATIVES = {
|
|
|
10132
10481
|
depth: 'Flat, front-facing layout.',
|
|
10133
10482
|
layout: 'Items reflow instantly.',
|
|
10134
10483
|
packs: 'Roles are styled but not animated.',
|
|
10484
|
+
fx: 'Effects are skipped or reduced to a short fade; the content is unchanged.',
|
|
10135
10485
|
};
|
|
10136
10486
|
/**
|
|
10137
10487
|
* Freeze a subtree at its static alternative: finishes running animations
|
|
@@ -10442,6 +10792,7 @@ const BY_CATEGORY = {
|
|
|
10442
10792
|
depth: defineDepthComponents,
|
|
10443
10793
|
layout: defineLayoutComponents,
|
|
10444
10794
|
packs: definePacksComponents,
|
|
10795
|
+
fx: defineFxComponents,
|
|
10445
10796
|
};
|
|
10446
10797
|
/**
|
|
10447
10798
|
* Register every `<usa-*>` component (or only the given categories).
|
|
@@ -10473,11 +10824,14 @@ exports.ALL_TAGS = ALL_TAGS;
|
|
|
10473
10824
|
exports.AMBIENT_EFFECTS = AMBIENT_EFFECTS;
|
|
10474
10825
|
exports.ANIM_ICONS = ANIM_ICONS;
|
|
10475
10826
|
exports.BRIDGE_PROTOCOL_VERSION = BRIDGE_PROTOCOL_VERSION;
|
|
10827
|
+
exports.BUILTIN_EFFECTS = BUILTIN_EFFECTS;
|
|
10476
10828
|
exports.BUTTON_DEFORMS = BUTTON_DEFORMS;
|
|
10477
10829
|
exports.CARD_EFFECTS = CARD_EFFECTS;
|
|
10478
10830
|
exports.CLICK_EFFECTS = CLICK_EFFECTS;
|
|
10479
10831
|
exports.COMPONENT_CATEGORIES = COMPONENT_CATEGORIES;
|
|
10480
10832
|
exports.CURSOR_MODES = CURSOR_MODES;
|
|
10833
|
+
exports.EFFECT_KINDS = EFFECT_KINDS;
|
|
10834
|
+
exports.EFFECT_TRIGGERS = EFFECT_TRIGGERS;
|
|
10481
10835
|
exports.GL_FALLBACKS = GL_FALLBACKS;
|
|
10482
10836
|
exports.JOINING_SCRIPT = JOINING_SCRIPT;
|
|
10483
10837
|
exports.LIVE_REGION_IDS = LIVE_REGION_IDS;
|
|
@@ -10505,6 +10859,7 @@ exports.VARIANTS = VARIANTS;
|
|
|
10505
10859
|
exports.activeAnimations = activeAnimations;
|
|
10506
10860
|
exports.adaptKeyframes = adaptKeyframes;
|
|
10507
10861
|
exports.adoptVariants = adoptVariants;
|
|
10862
|
+
exports.animateWithMotion = animateWithMotion;
|
|
10508
10863
|
exports.animationBudget = animationBudget;
|
|
10509
10864
|
exports.announce = announce;
|
|
10510
10865
|
exports.applyMotionTokens = applyMotionTokens;
|
|
@@ -10513,6 +10868,8 @@ exports.applyPack = applyPack;
|
|
|
10513
10868
|
exports.auditMotionA11y = auditMotionA11y;
|
|
10514
10869
|
exports.autoAnimate = autoAnimate;
|
|
10515
10870
|
exports.autoDegrade = autoDegrade;
|
|
10871
|
+
exports.baselineReport = baselineReport;
|
|
10872
|
+
exports.bindEffect = bindEffect;
|
|
10516
10873
|
exports.burst = burst;
|
|
10517
10874
|
exports.categoryOf = categoryOf;
|
|
10518
10875
|
exports.confetti = confetti;
|
|
@@ -10558,6 +10915,8 @@ exports.defineDrawer = defineDrawer;
|
|
|
10558
10915
|
exports.defineFab = defineFab;
|
|
10559
10916
|
exports.defineFeedbackComponents = defineFeedbackComponents;
|
|
10560
10917
|
exports.defineFullpage = defineFullpage;
|
|
10918
|
+
exports.defineFx = defineFx;
|
|
10919
|
+
exports.defineFxComponents = defineFxComponents;
|
|
10561
10920
|
exports.defineGestureComponents = defineGestureComponents;
|
|
10562
10921
|
exports.defineGlitch = defineGlitch;
|
|
10563
10922
|
exports.defineGradientText = defineGradientText;
|
|
@@ -10638,7 +10997,9 @@ exports.fluentPreset = fluentPreset;
|
|
|
10638
10997
|
exports.flyToCart = flyToCart;
|
|
10639
10998
|
exports.fragmentSource = fragmentSource;
|
|
10640
10999
|
exports.gesture = gesture;
|
|
11000
|
+
exports.getEffect = getEffect;
|
|
10641
11001
|
exports.getMotionIntensity = getMotionIntensity;
|
|
11002
|
+
exports.getMotionLevel = getMotionLevel;
|
|
10642
11003
|
exports.getMotionSensitivity = getMotionSensitivity;
|
|
10643
11004
|
exports.getMotionTokens = getMotionTokens;
|
|
10644
11005
|
exports.glFallbackCss = glFallbackCss;
|
|
@@ -10646,9 +11007,11 @@ exports.glGovernor = glGovernor;
|
|
|
10646
11007
|
exports.glQuad = glQuad;
|
|
10647
11008
|
exports.graphemes = graphemes;
|
|
10648
11009
|
exports.haptic = haptic;
|
|
11010
|
+
exports.hasEffect = hasEffect;
|
|
10649
11011
|
exports.importMotionTokens = importMotionTokens;
|
|
10650
11012
|
exports.interpolatePath = interpolatePath;
|
|
10651
11013
|
exports.linearEasing = linearEasing;
|
|
11014
|
+
exports.listEffects = listEffects;
|
|
10652
11015
|
exports.liveRegion = liveRegion;
|
|
10653
11016
|
exports.loadCategoryStyles = loadCategoryStyles;
|
|
10654
11017
|
exports.loadedStyles = loadedStyles;
|
|
@@ -10658,6 +11021,7 @@ exports.mergeMotionTokens = mergeMotionTokens;
|
|
|
10658
11021
|
exports.morphPath = morphPath;
|
|
10659
11022
|
exports.morphTo = morphTo;
|
|
10660
11023
|
exports.motionAllowed = motionAllowed;
|
|
11024
|
+
exports.motionScale = motionScale;
|
|
10661
11025
|
exports.motionToken = motionToken;
|
|
10662
11026
|
exports.motionTokensToCss = motionTokensToCss;
|
|
10663
11027
|
exports.motionTokensToJSON = motionTokensToJSON;
|
|
@@ -10672,11 +11036,15 @@ exports.parseEasing = parseEasing;
|
|
|
10672
11036
|
exports.parseNativeSettings = parseNativeSettings;
|
|
10673
11037
|
exports.pathsCompatible = pathsCompatible;
|
|
10674
11038
|
exports.pinchScale = pinchScale;
|
|
11039
|
+
exports.playEffect = playEffect;
|
|
10675
11040
|
exports.postFxShader = postFxShader;
|
|
10676
11041
|
exports.postToNative = postToNative;
|
|
10677
11042
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
10678
11043
|
exports.projectInertia = projectInertia;
|
|
10679
11044
|
exports.readScrollProgress = readScrollProgress;
|
|
11045
|
+
exports.registerBuiltinEffects = registerBuiltinEffects;
|
|
11046
|
+
exports.registerEffect = registerEffect;
|
|
11047
|
+
exports.registerEffects = registerEffects;
|
|
10680
11048
|
exports.requestOrientationPermission = requestOrientationPermission;
|
|
10681
11049
|
exports.resolveDurationToken = resolveDurationToken;
|
|
10682
11050
|
exports.resolveEasingToken = resolveEasingToken;
|
|
@@ -10691,6 +11059,7 @@ exports.scrambleFrame = scrambleFrame;
|
|
|
10691
11059
|
exports.scrollToTarget = scrollToTarget;
|
|
10692
11060
|
exports.setAnimationBudget = setAnimationBudget;
|
|
10693
11061
|
exports.setMotionIntensity = setMotionIntensity;
|
|
11062
|
+
exports.setMotionLevel = setMotionLevel;
|
|
10694
11063
|
exports.setMotionSensitivity = setMotionSensitivity;
|
|
10695
11064
|
exports.setVariant = setVariant;
|
|
10696
11065
|
exports.shake = shake;
|
|
@@ -10717,5 +11086,7 @@ exports.themeTransition = themeTransition;
|
|
|
10717
11086
|
exports.timeline = timeline;
|
|
10718
11087
|
exports.toast = toast;
|
|
10719
11088
|
exports.viewTransition = viewTransition;
|
|
11089
|
+
exports.warnBaseline = warnBaseline;
|
|
10720
11090
|
exports.watchPowerSaver = watchPowerSaver;
|
|
11091
|
+
exports.withoutDeprecations = withoutDeprecations;
|
|
10721
11092
|
//# sourceMappingURL=lite.cjs.map
|