kuinetic 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/esm/{chunk-7NW4OLOC.mjs → chunk-CG37RODK.mjs} +906 -428
- package/dist/esm/{chunk-DAVDOYOS.mjs → chunk-W7U4A2NK.mjs} +625 -124
- package/dist/esm/{chunk-4QKMEDM4.mjs → chunk-Y2FP56K5.mjs} +2501 -1694
- package/dist/esm/core/index.mjs +2 -2
- package/dist/esm/effects/index.mjs +2 -2
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/notes/index.mjs +75 -8
- package/dist/kuinetic.all.js +3977 -2221
- package/dist/kuinetic.all.min.js +4 -2
- package/dist/kuinetic.css +1248 -46
- package/dist/kuinetic.js +3976 -2220
- package/dist/kuinetic.min.css +1 -1
- package/dist/kuinetic.min.js +3 -1
- package/dist/kuinetic.notes.js +1 -1
- package/dist/types/core/animator.d.ts +61 -2
- package/dist/types/core/attrs.d.ts +0 -2
- package/dist/types/core/auto-motion.d.ts +139 -0
- package/dist/types/core/cadence.d.ts +90 -0
- package/dist/types/core/channels.d.ts +4 -0
- package/dist/types/core/compile.d.ts +14 -2
- package/dist/types/core/deck-viewer.d.ts +2 -0
- package/dist/types/core/declarations.d.ts +6 -0
- package/dist/types/core/derived/group-gate.d.ts +18 -4
- package/dist/types/core/describe.d.ts +1 -1
- package/dist/types/core/element-config.d.ts +3 -4
- package/dist/types/core/instances.d.ts +27 -3
- package/dist/types/core/params.d.ts +1 -2
- package/dist/types/core/parse.d.ts +20 -1
- package/dist/types/core/pause-scope.d.ts +40 -0
- package/dist/types/core/play.d.ts +2 -2
- package/dist/types/core/registry.d.ts +16 -1
- package/dist/types/core/repeat.d.ts +6 -4
- package/dist/types/core/sequence.d.ts +10 -0
- package/dist/types/core/stagger-config.d.ts +23 -101
- package/dist/types/core/stagger-keys.d.ts +2 -4
- package/dist/types/core/stagger.d.ts +12 -21
- package/dist/types/core/types.d.ts +65 -18
- package/dist/types/effects/auto-motion.d.ts +20 -123
- package/dist/types/effects/carousel/deck.d.ts +5 -0
- package/dist/types/effects/carousel/drag.d.ts +5 -0
- package/dist/types/effects/carousel/row-copies.d.ts +3 -0
- package/dist/types/effects/carousel/shape-fit.d.ts +8 -0
- package/dist/types/effects/catalog/feedback.d.ts +1 -1
- package/dist/types/effects/catalog/media-shared.d.ts +10 -0
- package/dist/types/effects/catalog/pause-scope.d.ts +20 -0
- package/dist/types/effects/catalog/text-shared.d.ts +4 -0
- package/dist/types/effects/scroll-mechanics/snap-autoplay.d.ts +20 -0
- package/dist/types/effects/step-index.d.ts +19 -1
- package/dist/types/effects/svg/morph-loop.d.ts +2 -0
- package/dist/types/effects/tween/waypoints.d.ts +1 -1
- package/dist/types/showcase/media-source.d.ts +1 -0
- package/dist/types/showcase/youtube.d.ts +3 -0
- package/package.json +1 -1
|
@@ -46,6 +46,41 @@ function queryControls(el, ctx, selector) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// src/core/event-sources.ts
|
|
49
|
+
var NATIVE_CONTROLS = "button, input, select, textarea, a[href], summary, audio[controls], video[controls]";
|
|
50
|
+
var NESTED_CONTROLS = `${NATIVE_CONTROLS}, [tabindex], [contenteditable], [role="button"], [role="link"], [role="checkbox"], [role="radio"], [role="switch"], [role="textbox"], [role="combobox"], [role="slider"], [role="tab"], [role^="menuitem"]`;
|
|
51
|
+
function bindButtonKeys(source) {
|
|
52
|
+
const button = source;
|
|
53
|
+
if (!source.matches('[role="button"][tabindex]') || typeof button.click !== "function" || source.matches(NATIVE_CONTROLS)) return;
|
|
54
|
+
let space = false;
|
|
55
|
+
const blur = () => {
|
|
56
|
+
space = false;
|
|
57
|
+
};
|
|
58
|
+
const eligible = (event) => {
|
|
59
|
+
const control2 = event.composedPath().find((target) => target === source || target.matches?.(NESTED_CONTROLS));
|
|
60
|
+
return !event.defaultPrevented && source.hasAttribute("tabindex") && source.matches(":focus") && !source.matches(':disabled, [disabled], [aria-disabled="true"]') && control2 === source;
|
|
61
|
+
};
|
|
62
|
+
const down = (event) => {
|
|
63
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
64
|
+
if (!eligible(event)) return;
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
if (event.repeat) return;
|
|
67
|
+
if (event.key === "Enter") button.click();
|
|
68
|
+
else space = true;
|
|
69
|
+
};
|
|
70
|
+
const up = (event) => {
|
|
71
|
+
if (event.key !== " " || !space) return;
|
|
72
|
+
blur();
|
|
73
|
+
if (!event.repeat && eligible(event)) button.click();
|
|
74
|
+
};
|
|
75
|
+
button.addEventListener("keydown", down);
|
|
76
|
+
button.addEventListener("keyup", up);
|
|
77
|
+
button.addEventListener("blur", blur);
|
|
78
|
+
return () => {
|
|
79
|
+
button.removeEventListener("keydown", down);
|
|
80
|
+
button.removeEventListener("keyup", up);
|
|
81
|
+
button.removeEventListener("blur", blur);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
49
84
|
function createEventSourceBindings() {
|
|
50
85
|
const bindings = /* @__PURE__ */ new Map();
|
|
51
86
|
function retain(source, type, run) {
|
|
@@ -60,7 +95,7 @@ function createEventSourceBindings() {
|
|
|
60
95
|
const listener = () => {
|
|
61
96
|
for (const callback of [...runs]) callback();
|
|
62
97
|
};
|
|
63
|
-
binding = { listener, runs };
|
|
98
|
+
binding = { listener, runs, releaseKeys: type === "click" ? bindButtonKeys(source) : void 0 };
|
|
64
99
|
types.set(type, binding);
|
|
65
100
|
source.addEventListener(type, listener, { passive: true });
|
|
66
101
|
}
|
|
@@ -72,6 +107,7 @@ function createEventSourceBindings() {
|
|
|
72
107
|
binding.runs.delete(run);
|
|
73
108
|
if (binding.runs.size > 0) return;
|
|
74
109
|
source.removeEventListener(type, binding.listener);
|
|
110
|
+
binding.releaseKeys?.();
|
|
75
111
|
types?.delete(type);
|
|
76
112
|
if (types?.size === 0) bindings.delete(source);
|
|
77
113
|
};
|
|
@@ -88,7 +124,10 @@ function createEventSourceBindings() {
|
|
|
88
124
|
},
|
|
89
125
|
destroy() {
|
|
90
126
|
for (const [source, types] of bindings) {
|
|
91
|
-
for (const [type, binding] of types)
|
|
127
|
+
for (const [type, binding] of types) {
|
|
128
|
+
source.removeEventListener(type, binding.listener);
|
|
129
|
+
binding.releaseKeys?.();
|
|
130
|
+
}
|
|
92
131
|
}
|
|
93
132
|
bindings.clear();
|
|
94
133
|
}
|
|
@@ -420,7 +459,6 @@ function sideOf(entry) {
|
|
|
420
459
|
}
|
|
421
460
|
function createActivationBinder(options = {}) {
|
|
422
461
|
const observers = /* @__PURE__ */ new Map();
|
|
423
|
-
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
424
462
|
const eventBindings = createEventSourceBindings();
|
|
425
463
|
const createObserver = options.createObserver ?? defaultObserverFactory();
|
|
426
464
|
const travel = createTravelTracker();
|
|
@@ -431,16 +469,21 @@ function createActivationBinder(options = {}) {
|
|
|
431
469
|
const key = String(ratio);
|
|
432
470
|
const existing = observers.get(key);
|
|
433
471
|
if (existing) return { key, shared: existing };
|
|
472
|
+
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
434
473
|
const observer = createObserver(
|
|
435
474
|
(entries) => {
|
|
436
475
|
for (const entry of entries) {
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
476
|
+
const bindings = callbacks.get(entry.target);
|
|
477
|
+
if (!bindings) continue;
|
|
478
|
+
const from = travel.arrivedFrom(entry.time);
|
|
479
|
+
for (const binding of [...bindings]) {
|
|
480
|
+
if (bindings.has(binding)) deliverEntry(binding, entry, ratio, from);
|
|
481
|
+
}
|
|
439
482
|
}
|
|
440
483
|
},
|
|
441
484
|
{ threshold: ratio }
|
|
442
485
|
);
|
|
443
|
-
const shared = { observer, count: 0 };
|
|
486
|
+
const shared = { observer, callbacks, count: 0 };
|
|
444
487
|
observers.set(key, shared);
|
|
445
488
|
return { key, shared };
|
|
446
489
|
}
|
|
@@ -453,19 +496,23 @@ function createActivationBinder(options = {}) {
|
|
|
453
496
|
const { key, shared } = binding;
|
|
454
497
|
const tracksTravel = Boolean(spec.onCross);
|
|
455
498
|
if (tracksTravel) travel.retain();
|
|
499
|
+
const bindings = shared.callbacks.get(el) ?? /* @__PURE__ */ new Set();
|
|
456
500
|
let active = true;
|
|
457
501
|
const release = () => {
|
|
458
502
|
if (!active) return;
|
|
459
503
|
active = false;
|
|
460
504
|
if (tracksTravel) travel.release();
|
|
461
|
-
|
|
462
|
-
|
|
505
|
+
bindings.delete(observed);
|
|
506
|
+
if (bindings.size === 0) {
|
|
507
|
+
shared.callbacks.delete(el);
|
|
508
|
+
shared.observer.unobserve(el);
|
|
509
|
+
}
|
|
463
510
|
shared.count--;
|
|
464
511
|
if (shared.count > 0) return;
|
|
465
512
|
shared.observer.disconnect();
|
|
466
513
|
observers.delete(key);
|
|
467
514
|
};
|
|
468
|
-
|
|
515
|
+
const observed = {
|
|
469
516
|
onEnter: spec.onEnter,
|
|
470
517
|
onLeave: spec.onLeave,
|
|
471
518
|
...spec.onCross ? { onCross: spec.onCross } : {},
|
|
@@ -475,9 +522,13 @@ function createActivationBinder(options = {}) {
|
|
|
475
522
|
reporter,
|
|
476
523
|
sawIntersecting: false,
|
|
477
524
|
thresholdWarned: false
|
|
478
|
-
}
|
|
525
|
+
};
|
|
526
|
+
bindings.add(observed);
|
|
479
527
|
shared.count++;
|
|
480
|
-
|
|
528
|
+
if (bindings.size === 1) {
|
|
529
|
+
shared.callbacks.set(el, bindings);
|
|
530
|
+
shared.observer.observe(el);
|
|
531
|
+
}
|
|
481
532
|
return release;
|
|
482
533
|
}
|
|
483
534
|
return {
|
|
@@ -552,16 +603,16 @@ function defaultObserverFactory() {
|
|
|
552
603
|
function onlyBoundLate(name, claims) {
|
|
553
604
|
const authorising = authorisingActivations(name);
|
|
554
605
|
if (!authorising.includes("enter")) return false;
|
|
555
|
-
const suits = (
|
|
556
|
-
if (!claims.some((
|
|
557
|
-
return claims.every((
|
|
606
|
+
const suits = (claim) => authorising.some((named) => claim.supported.includes(named));
|
|
607
|
+
if (!claims.some((claim) => claim.entrance && suits(claim))) return false;
|
|
608
|
+
return claims.every((claim) => suits(claim) || claim.supported.includes("load"));
|
|
558
609
|
}
|
|
559
610
|
function warnAboutActivation(request) {
|
|
560
611
|
warnUnsupported(request);
|
|
561
612
|
warnUnknownEvents(request);
|
|
562
613
|
}
|
|
563
614
|
function warnUnsupported({ el, spec, supported, claims, reporter }) {
|
|
564
|
-
const declaredAny = supported.length > 0 || (claims?.some((
|
|
615
|
+
const declaredAny = supported.length > 0 || (claims?.some((claim) => claim.supported.length > 0) ?? false);
|
|
565
616
|
if (!declaredAny) return;
|
|
566
617
|
const shared = supported.length > 0 ? supported.join(", ") : "none in common across the composed effects";
|
|
567
618
|
for (const name of spec.names) {
|
|
@@ -594,9 +645,7 @@ var ATTR = {
|
|
|
594
645
|
normalized: "data-kui-fx",
|
|
595
646
|
state: "data-kui-state",
|
|
596
647
|
on: "data-kui-on",
|
|
597
|
-
timeline: "data-kui-timeline",
|
|
598
648
|
threshold: "data-kui-threshold",
|
|
599
|
-
stagger: "data-kui-stagger",
|
|
600
649
|
cloak: "data-kui-cloak",
|
|
601
650
|
/** Reduced-motion policy, stamped from the primitive so the CSS layer can act on it. */
|
|
602
651
|
rm: "data-kui-rm",
|
|
@@ -649,8 +698,10 @@ function inertInstance(destroy = () => {
|
|
|
649
698
|
}
|
|
650
699
|
var SEGMENT_HOIST_KEYS = [
|
|
651
700
|
"activation",
|
|
701
|
+
"via",
|
|
652
702
|
"actions",
|
|
653
703
|
"timeline",
|
|
704
|
+
"range",
|
|
654
705
|
"threshold",
|
|
655
706
|
"cascade",
|
|
656
707
|
"spread",
|
|
@@ -663,6 +714,7 @@ var SEGMENT_HOIST_KEYS = [
|
|
|
663
714
|
var Registry = class {
|
|
664
715
|
primitives = /* @__PURE__ */ new Map();
|
|
665
716
|
presets = /* @__PURE__ */ new Map();
|
|
717
|
+
splitProviders = /* @__PURE__ */ new Map();
|
|
666
718
|
/** Sorted-name key → preset that renders that combination as one tested keyframe. */
|
|
667
719
|
combos = /* @__PURE__ */ new Map();
|
|
668
720
|
registerPrimitive(primitive) {
|
|
@@ -699,6 +751,13 @@ var Registry = class {
|
|
|
699
751
|
for (const primitive of primitives) this.registerPrimitive(primitive);
|
|
700
752
|
return this;
|
|
701
753
|
}
|
|
754
|
+
registerSplitProvider(unit, install) {
|
|
755
|
+
this.splitProviders.set(unit, install);
|
|
756
|
+
return this;
|
|
757
|
+
}
|
|
758
|
+
getSplitProvider(unit) {
|
|
759
|
+
return this.splitProviders.get(unit);
|
|
760
|
+
}
|
|
702
761
|
/**
|
|
703
762
|
* Declare that a set of effect names has a purpose-built single-keyframe implementation.
|
|
704
763
|
* Checked before channel conflict analysis, so `fade-up` + `blur-in` can resolve to the
|
|
@@ -1160,16 +1219,23 @@ function round(value) {
|
|
|
1160
1219
|
// src/core/repeat.ts
|
|
1161
1220
|
var INFINITE = "infinite";
|
|
1162
1221
|
var COUNT_RE = /^(?:\d+(?:\.\d+)?|\.\d+)$/;
|
|
1222
|
+
var GAP_RE = /^(\d+(?:\.\d+)?|\.\d+)(ms|s)$/;
|
|
1163
1223
|
var PROGRESS_DRIVEN = /* @__PURE__ */ new Set(["view", "scroll", "pin"]);
|
|
1164
|
-
var PLAYBACK_KEYS = /* @__PURE__ */ new Set(["repeat", "yoyo"]);
|
|
1224
|
+
var PLAYBACK_KEYS = /* @__PURE__ */ new Set(["repeat", "repeat-delay", "yoyo"]);
|
|
1165
1225
|
function isPlaybackKey(key) {
|
|
1166
1226
|
return PLAYBACK_KEYS.has(key);
|
|
1167
1227
|
}
|
|
1168
1228
|
function applyPlayback(spec, key, value, context) {
|
|
1169
|
-
|
|
1229
|
+
const field = key === "repeat-delay" ? "repeatDelay" : key;
|
|
1230
|
+
if (spec[field] !== void 0) {
|
|
1170
1231
|
context.warn(`duplicate parameter "${key}" in "${context.segment}"`);
|
|
1171
1232
|
}
|
|
1172
|
-
if (key === "
|
|
1233
|
+
if (key === "repeat-delay") {
|
|
1234
|
+
const match = GAP_RE.exec(value);
|
|
1235
|
+
const ms = Number(match?.[1]) * (match?.[2] === "s" ? 1e3 : 1);
|
|
1236
|
+
if (Number.isFinite(ms)) spec.repeatDelay = ms;
|
|
1237
|
+
else context.warn(`"repeat-delay:${value}" in "${context.segment}" needs a nonnegative literal time in ms or s`);
|
|
1238
|
+
} else if (key === "yoyo") applyYoyo(spec, value, context);
|
|
1173
1239
|
else applyRepeat(spec, value, context);
|
|
1174
1240
|
}
|
|
1175
1241
|
function applyRepeat(spec, value, context) {
|
|
@@ -1206,7 +1272,7 @@ function countRefusal(value, segment) {
|
|
|
1206
1272
|
function resolvePlayback(input) {
|
|
1207
1273
|
const warnings = [];
|
|
1208
1274
|
if (input.repeat === void 0 && input.yoyo === void 0) return { warnings };
|
|
1209
|
-
if (input.renderer !== "css-keyframes") return
|
|
1275
|
+
if (input.renderer !== "css-keyframes") return resolveJsPlayback(input);
|
|
1210
1276
|
if (input.repeat === INFINITE && PROGRESS_DRIVEN.has(input.timeline)) {
|
|
1211
1277
|
warnings.push(infiniteTimelineRefusal(input.name, input.timeline));
|
|
1212
1278
|
return { yoyo: input.yoyo, warnings };
|
|
@@ -1215,6 +1281,31 @@ function resolvePlayback(input) {
|
|
|
1215
1281
|
if (hidden) warnings.push(hidden);
|
|
1216
1282
|
return { repeat: input.repeat, yoyo: input.yoyo, warnings };
|
|
1217
1283
|
}
|
|
1284
|
+
function resolveJsPlayback(input) {
|
|
1285
|
+
if (input.repeatable !== true) return { warnings: [rendererRefusal(input)] };
|
|
1286
|
+
const warnings = [];
|
|
1287
|
+
let repeat = input.repeat;
|
|
1288
|
+
if (repeat !== void 0 && repeat !== INFINITE) {
|
|
1289
|
+
const count = Number(repeat);
|
|
1290
|
+
if (count === 0) {
|
|
1291
|
+
warnings.push(
|
|
1292
|
+
`"${input.name}" has repeat:0, which would never start. Dropping the repeat so it plays once \u2014 remove the key, or write repeat:infinite to loop.`
|
|
1293
|
+
);
|
|
1294
|
+
repeat = void 0;
|
|
1295
|
+
} else if (!Number.isInteger(count)) {
|
|
1296
|
+
warnings.push(
|
|
1297
|
+
`"${input.name}" has repeat:${repeat}, but a JS-rendered effect repeats whole runs. Dropping the repeat so it plays once \u2014 use a whole number such as repeat:3.`
|
|
1298
|
+
);
|
|
1299
|
+
repeat = void 0;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
if (input.yoyo !== void 0) {
|
|
1303
|
+
warnings.push(
|
|
1304
|
+
`"${input.name}" is rendered in JavaScript, which has no playhead to run backwards, so yoyo:${input.yoyo} has nothing to alternate and is ignored. repeat: still replays it.`
|
|
1305
|
+
);
|
|
1306
|
+
}
|
|
1307
|
+
return { repeat, warnings };
|
|
1308
|
+
}
|
|
1218
1309
|
function endsHidden(input) {
|
|
1219
1310
|
if (!input.cloak || input.yoyo !== true) return null;
|
|
1220
1311
|
const count = repeatCount(input.repeat);
|
|
@@ -1226,7 +1317,7 @@ function rendererRefusal(input) {
|
|
|
1226
1317
|
input.repeat === void 0 ? "" : `repeat:${input.repeat}`,
|
|
1227
1318
|
input.yoyo === void 0 ? "" : `yoyo:${input.yoyo}`
|
|
1228
1319
|
].filter(Boolean).join(" and ");
|
|
1229
|
-
return `"${input.name}" is rendered in JavaScript and compiles no animation-iteration-count, so ${authored} does nothing \u2014 it plays once.
|
|
1320
|
+
return `"${input.name}" is rendered in JavaScript and compiles no animation-iteration-count, so ${authored} does nothing \u2014 it plays once. Finite JS effects such as slat-assemble, count-up and split-text can repeat; this one is continuous or stateful, so a replay would mean nothing. A CSS effect repeats and yoyos natively.`;
|
|
1230
1321
|
}
|
|
1231
1322
|
function infiniteTimelineRefusal(name, timeline) {
|
|
1232
1323
|
const because = timeline === "pin" ? `a pin scrubs a single playthrough with a negative animation-delay, so no iteration past the first is ever reachable` : `a "${timeline}" timeline is a finite range driven by scroll position rather than a clock, and an infinite iteration count collapses the animation's active duration to zero there \u2014 the element renders frozen at its end state`;
|
|
@@ -1242,10 +1333,11 @@ function isInfiniteRepeat(repeat) {
|
|
|
1242
1333
|
function directionValue(yoyo) {
|
|
1243
1334
|
return yoyo ? "alternate" : "normal";
|
|
1244
1335
|
}
|
|
1245
|
-
function playbackExpression(duration, repeat) {
|
|
1336
|
+
function playbackExpression(duration, repeat, gap) {
|
|
1246
1337
|
const count = repeatCount(repeat);
|
|
1247
1338
|
if (count === void 0 || count === 1) return duration;
|
|
1248
|
-
|
|
1339
|
+
const holds = gap ? ` + ${gap * (count - 1)}ms` : "";
|
|
1340
|
+
return `${duration} * ${count}${holds}`;
|
|
1249
1341
|
}
|
|
1250
1342
|
|
|
1251
1343
|
// src/core/toggle-actions.ts
|
|
@@ -1421,7 +1513,7 @@ function splitPair(token) {
|
|
|
1421
1513
|
else if (char === ":" && depth === 0) {
|
|
1422
1514
|
const key = token.slice(0, i).trim();
|
|
1423
1515
|
const value = unquote(token.slice(i + 1).trim());
|
|
1424
|
-
return key && value ? [key, value] : null;
|
|
1516
|
+
return key && (value || key === "split" || key === "values") ? [key, value] : null;
|
|
1425
1517
|
}
|
|
1426
1518
|
}
|
|
1427
1519
|
return null;
|
|
@@ -1484,12 +1576,16 @@ function parseSegment(segment, result) {
|
|
|
1484
1576
|
}
|
|
1485
1577
|
const spec = { name, params: {} };
|
|
1486
1578
|
let timeCount = 0;
|
|
1487
|
-
const sink =
|
|
1579
|
+
const sink = hasGroupTarget(tokens) ? { specs: [], warnings: [] } : null;
|
|
1488
1580
|
for (const raw of tokens) {
|
|
1489
1581
|
const token = classify(raw);
|
|
1490
1582
|
if (token.kind === "time") timeCount = applyTime(spec, token.value, timeCount, result.warnings);
|
|
1491
1583
|
else applyToken(token, spec, { segment, result, sink });
|
|
1492
1584
|
}
|
|
1585
|
+
if (spec.split === "tiles" && spec.params.rows !== void 0) {
|
|
1586
|
+
spec.rows = spec.params.rows;
|
|
1587
|
+
delete spec.params.rows;
|
|
1588
|
+
}
|
|
1493
1589
|
attachSegmentHoists(spec, sink, result);
|
|
1494
1590
|
return spec;
|
|
1495
1591
|
}
|
|
@@ -1499,8 +1595,11 @@ function attachSegmentHoists(spec, sink, result) {
|
|
|
1499
1595
|
const hoists = collectHoists(sink);
|
|
1500
1596
|
if (hoists) spec.hoists = hoists;
|
|
1501
1597
|
}
|
|
1502
|
-
function
|
|
1503
|
-
return tokens.some((
|
|
1598
|
+
function hasGroupTarget(tokens) {
|
|
1599
|
+
return tokens.some((token) => {
|
|
1600
|
+
const pair = splitPair(token);
|
|
1601
|
+
return pair?.[0] === "target" || pair?.[0] === "split" && ["chars", "words", "tiles"].includes(pair[1]);
|
|
1602
|
+
});
|
|
1504
1603
|
}
|
|
1505
1604
|
function collectHoists(sink) {
|
|
1506
1605
|
const hoists = {};
|
|
@@ -1515,8 +1614,10 @@ function collectHoists(sink) {
|
|
|
1515
1614
|
}
|
|
1516
1615
|
var SEGMENT_SCOPABLE_HOISTS = /* @__PURE__ */ new Set([
|
|
1517
1616
|
"on",
|
|
1617
|
+
"via",
|
|
1518
1618
|
"actions",
|
|
1519
1619
|
"timeline",
|
|
1620
|
+
"range",
|
|
1520
1621
|
"threshold",
|
|
1521
1622
|
"cascade",
|
|
1522
1623
|
"spread",
|
|
@@ -1541,6 +1642,11 @@ var GROUP_ONLY_HOISTS = /* @__PURE__ */ new Set([
|
|
|
1541
1642
|
"cols",
|
|
1542
1643
|
"along"
|
|
1543
1644
|
]);
|
|
1645
|
+
function isGroupOnly(parsed) {
|
|
1646
|
+
if (parsed.specs.length > 0) return false;
|
|
1647
|
+
for (const key of GROUP_ONLY_HOISTS) if (Object.hasOwn(parsed, key)) return true;
|
|
1648
|
+
return false;
|
|
1649
|
+
}
|
|
1544
1650
|
function applyTime(spec, value, seen, warnings) {
|
|
1545
1651
|
if (seen === 0) spec.duration = value;
|
|
1546
1652
|
else if (seen === 1) spec.delay = value;
|
|
@@ -1579,6 +1685,11 @@ function applyEasing(value, spec, segment, result) {
|
|
|
1579
1685
|
}
|
|
1580
1686
|
function applyLifted(key, value, spec, context) {
|
|
1581
1687
|
const { segment, result } = context;
|
|
1688
|
+
if (key === "split") {
|
|
1689
|
+
if (value === "chars" || value === "words" || value === "tiles") spec.split = value;
|
|
1690
|
+
else result.warnings.push(`invalid value "${value}" for "split:" \u2014 expected "chars", "words", or "tiles"`);
|
|
1691
|
+
return true;
|
|
1692
|
+
}
|
|
1582
1693
|
if (key === "at") {
|
|
1583
1694
|
if (spec.at !== void 0) result.warnings.push(`duplicate parameter "at" in "${segment}"`);
|
|
1584
1695
|
spec.at = value;
|
|
@@ -1645,9 +1756,15 @@ var HOISTS = {
|
|
|
1645
1756
|
}
|
|
1646
1757
|
assignOnce(result, "activation", value, "activations");
|
|
1647
1758
|
},
|
|
1759
|
+
via(result, value) {
|
|
1760
|
+
assignOnce(result, "via", value, "activation sources");
|
|
1761
|
+
},
|
|
1648
1762
|
timeline(result, value) {
|
|
1649
1763
|
assignOnce(result, "timeline", value, "timelines");
|
|
1650
1764
|
},
|
|
1765
|
+
range(result, value) {
|
|
1766
|
+
assignOnce(result, "range", value, "ranges");
|
|
1767
|
+
},
|
|
1651
1768
|
/**
|
|
1652
1769
|
* What to do at each of a scroll trigger's four crossings —
|
|
1653
1770
|
* `actions:play/pause/resume/reset`, in the order enter, leave, enter-back, leave-back.
|
|
@@ -1671,10 +1788,8 @@ var HOISTS = {
|
|
|
1671
1788
|
assignOnce(result, "threshold", value, "thresholds");
|
|
1672
1789
|
},
|
|
1673
1790
|
/**
|
|
1674
|
-
* Deliberately unvalidated here
|
|
1675
|
-
*
|
|
1676
|
-
* two spellings have to accept the same values or "move it into `data-kui`" would silently be a
|
|
1677
|
-
* narrowing. `stagger.ts` owns the one screen both spellings get.
|
|
1791
|
+
* Deliberately unvalidated here so `var(--speed)` and `calc(90ms * 2)` work.
|
|
1792
|
+
* `stagger-config.ts` screens the step before it reaches `--kui-stagger`.
|
|
1678
1793
|
*/
|
|
1679
1794
|
cascade(result, value) {
|
|
1680
1795
|
warnStepMode(result, "spread", "cascade", value);
|
|
@@ -1717,7 +1832,7 @@ var HOISTS = {
|
|
|
1717
1832
|
* Spelled `along:` rather than GSAP's `axis:` for the same reason `order:` is not `from:`: `axis`
|
|
1718
1833
|
* is a parameter on four primitives (`parallax`, `slat-assemble`, and both draggables) and a
|
|
1719
1834
|
* hoisted key never reaches `spec.params`, so lifting the word element-wide would make
|
|
1720
|
-
* `data-kui="parallax-y axis:x"` unwritable.
|
|
1835
|
+
* `data-kui="parallax-y axis:x"` unwritable.
|
|
1721
1836
|
*/
|
|
1722
1837
|
along(result, value) {
|
|
1723
1838
|
assignOnce(result, "along", value, "stagger axes");
|
|
@@ -1759,8 +1874,31 @@ var HOISTS = {
|
|
|
1759
1874
|
*/
|
|
1760
1875
|
func(result, value) {
|
|
1761
1876
|
assignOnce(result, "func", value, "callbacks");
|
|
1877
|
+
},
|
|
1878
|
+
/**
|
|
1879
|
+
* Replay cadence — `every:2.6s` performs one demonstration step per period while the element is
|
|
1880
|
+
* on screen and nothing pauses it (the runtime lives in `animator.ts`/`cadence.ts`).
|
|
1881
|
+
*
|
|
1882
|
+
* Element-wide always: it is deliberately absent from `SEGMENT_SCOPABLE_HOISTS`, because one
|
|
1883
|
+
* element has one cadence whatever its `target:` groups do — the `rm:`/`func:` rule. Validated
|
|
1884
|
+
* here as a non-negative time token, since the value is only ever a period; the floor that stops
|
|
1885
|
+
* a 50ms loop is a runtime concern and warns there. The word is `every` rather than
|
|
1886
|
+
* `loop`/`interval`/`autoplay`/`pause`/`hold`/`rest` because every one of those is already a
|
|
1887
|
+
* primitive parameter, and a hoisted key never reaches `spec.params` — hoisting one would make
|
|
1888
|
+
* those effects unwritable (the `from:`→`order:` collision above).
|
|
1889
|
+
*/
|
|
1890
|
+
every(result, value) {
|
|
1891
|
+
if (!TIME_RE.test(value) || value.startsWith("-")) {
|
|
1892
|
+
result.warnings.push(`unrecognised "every:${value}" \u2014 expected a positive time such as 2.6s or 900ms`);
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
assignOnce(result, "every", value, "replay cadences");
|
|
1762
1896
|
}
|
|
1763
1897
|
};
|
|
1898
|
+
var ELEMENT_HOIST_KEYS = Object.keys(HOISTS);
|
|
1899
|
+
function tokenKind(token) {
|
|
1900
|
+
return classify(token).kind;
|
|
1901
|
+
}
|
|
1764
1902
|
function warnStepMode(result, other, key, value) {
|
|
1765
1903
|
const written = result[other];
|
|
1766
1904
|
if (written === void 0) return;
|
|
@@ -1842,22 +1980,56 @@ function toAttributeValue(effect, options = {}) {
|
|
|
1842
1980
|
}
|
|
1843
1981
|
return parts.join(" ");
|
|
1844
1982
|
}
|
|
1983
|
+
function mergeAuthoredStep(source, effect, fallback) {
|
|
1984
|
+
const steps = splitTopLevel(source, ",");
|
|
1985
|
+
const step = steps.find((candidate) => splitTopLevel(candidate, " ")[0] === effect);
|
|
1986
|
+
if (!step) return fallback;
|
|
1987
|
+
const [, ...overrides] = splitTopLevel(fallback, " ");
|
|
1988
|
+
if (overrides.length === 0) return steps.length === 1 ? source : step;
|
|
1989
|
+
const [, ...authored] = splitTopLevel(step, " ");
|
|
1990
|
+
const timeSlots = ["duration", "delay"];
|
|
1991
|
+
let overrideTime = 0;
|
|
1992
|
+
const replacements = new Map(overrides.map((token) => {
|
|
1993
|
+
const kind = tokenKind(token);
|
|
1994
|
+
if (kind === "time") return [timeSlots[overrideTime++] ?? Symbol(), token];
|
|
1995
|
+
if (kind === "easing") return ["ease", token];
|
|
1996
|
+
if (kind === "pair") return [token.split(":", 1)[0], token];
|
|
1997
|
+
return [Symbol(), token];
|
|
1998
|
+
}));
|
|
1999
|
+
const overridden = new Set(replacements.keys());
|
|
2000
|
+
const hasDuration = overridden.has("duration") || authored.some((token) => tokenKind(token) === "time");
|
|
2001
|
+
const delay = replacements.get("delay");
|
|
2002
|
+
if (hasDuration && delay?.startsWith("delay:")) replacements.set("delay", delay.slice("delay:".length));
|
|
2003
|
+
let authoredTime = 0;
|
|
2004
|
+
const merged = authored.flatMap((token) => {
|
|
2005
|
+
const kind = tokenKind(token);
|
|
2006
|
+
if (kind === "pair") return overridden.has(token.split(":", 1)[0]) ? [] : [token];
|
|
2007
|
+
let key;
|
|
2008
|
+
if (kind === "time") key = timeSlots[authoredTime++];
|
|
2009
|
+
if (kind === "easing") key = "ease";
|
|
2010
|
+
if (key === void 0 || !overridden.has(key)) return [token];
|
|
2011
|
+
const replacement = replacements.get(key);
|
|
2012
|
+
replacements.delete(key);
|
|
2013
|
+
return replacement === void 0 ? [] : [replacement];
|
|
2014
|
+
});
|
|
2015
|
+
return [effect, ...merged, ...replacements.values()].join(" ");
|
|
2016
|
+
}
|
|
1845
2017
|
function play(request, options = {}) {
|
|
1846
2018
|
const { animator, root, target, effect } = request;
|
|
1847
2019
|
const elements = resolveTargets(target, root);
|
|
1848
2020
|
const stagger = time(options.stagger);
|
|
1849
|
-
const
|
|
2021
|
+
const fallback = toAttributeValue(effect, options);
|
|
1850
2022
|
for (const [index, el] of elements.entries()) {
|
|
1851
2023
|
if (stagger) {
|
|
1852
2024
|
;
|
|
1853
2025
|
el.style.setProperty("--kui-stagger", stagger);
|
|
1854
2026
|
el.style.setProperty("--kui-i", String(index));
|
|
1855
2027
|
}
|
|
1856
|
-
|
|
2028
|
+
const authored = el.getAttribute(ATTR.source);
|
|
2029
|
+
const source = mergeAuthoredStep(authored ?? "", effect, fallback);
|
|
1857
2030
|
if (!el.hasAttribute(ATTR.on)) el.setAttribute(ATTR.on, "manual");
|
|
1858
|
-
el.setAttribute(ATTR.source, source);
|
|
1859
|
-
animator.
|
|
1860
|
-
animator.activate(el);
|
|
2031
|
+
if (source !== authored) el.setAttribute(ATTR.source, source);
|
|
2032
|
+
animator.replay(el);
|
|
1861
2033
|
}
|
|
1862
2034
|
const instancesOf = (el) => [el, ...animator.derivedOf(el)].flatMap((each) => animator.stateOf(each)?.instances ?? []);
|
|
1863
2035
|
const finished = Promise.all(
|
|
@@ -2089,6 +2261,36 @@ function timingContractOf(primitive) {
|
|
|
2089
2261
|
return primitive.prepare ? CONTRACTS.get(primitive.prepare) : void 0;
|
|
2090
2262
|
}
|
|
2091
2263
|
|
|
2264
|
+
// src/core/deck-viewer.ts
|
|
2265
|
+
var provided = null;
|
|
2266
|
+
function provideDeckViewer(viewer) {
|
|
2267
|
+
provided = viewer;
|
|
2268
|
+
}
|
|
2269
|
+
function attachDeckViewer(request) {
|
|
2270
|
+
return provided ? provided(request) : null;
|
|
2271
|
+
}
|
|
2272
|
+
var VIEWER_EVENT = "kui:viewer";
|
|
2273
|
+
function announceViewer(doc, opener, open) {
|
|
2274
|
+
const Ctor = doc.defaultView?.CustomEvent ?? CustomEvent;
|
|
2275
|
+
const source = opener.isConnected ? opener : doc;
|
|
2276
|
+
source.dispatchEvent(new Ctor(VIEWER_EVENT, { bubbles: true, detail: { open } }));
|
|
2277
|
+
}
|
|
2278
|
+
var DECK_LIGHTBOX_PARAM = {
|
|
2279
|
+
type: "keyword",
|
|
2280
|
+
default: "false",
|
|
2281
|
+
cssProperty: "--kui-deck-lightbox",
|
|
2282
|
+
keywords: ["true", "false"]
|
|
2283
|
+
};
|
|
2284
|
+
function deckLightbox(enabled, request, warn) {
|
|
2285
|
+
if (!enabled) return () => {
|
|
2286
|
+
};
|
|
2287
|
+
const release = attachDeckViewer(request);
|
|
2288
|
+
if (release) return release;
|
|
2289
|
+
warn("lightbox:true needs the showcase module (the lightbox gallery), which is not loaded; cards will not open");
|
|
2290
|
+
return () => {
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2092
2294
|
// src/core/params.ts
|
|
2093
2295
|
var DANGEROUS = /[;<]|\/\*|url\s*\(|expression\s*\(|@import|image-set\s*\(/i;
|
|
2094
2296
|
var ABSOLUTE_OR_PROTOCOL_RELATIVE = /^(?:[a-z][a-z0-9+.-]*:|[/\\]{2})/i;
|
|
@@ -2290,13 +2492,14 @@ var EASING_FUNCTION = /^(?:cubic-bezier|steps|linear|spring)\([^()]*\)$/i;
|
|
|
2290
2492
|
var UNION_GRAMMARS = {
|
|
2291
2493
|
"number|percentage": ["number", "percentage"],
|
|
2292
2494
|
"length|percentage": ["length", "percentage"],
|
|
2293
|
-
"angle|keyword": ["angle"]
|
|
2495
|
+
"angle|keyword": ["angle"],
|
|
2496
|
+
"number|keyword": ["number"]
|
|
2294
2497
|
};
|
|
2295
2498
|
function grammarsFor(type) {
|
|
2296
2499
|
return UNION_GRAMMARS[type] ?? [type];
|
|
2297
2500
|
}
|
|
2298
|
-
var CALC_TYPES = /* @__PURE__ */ new Set(["length", "percentage", "number"]);
|
|
2299
|
-
var BOUNDED_TYPES = /* @__PURE__ */ new Set(["number", "number|percentage"]);
|
|
2501
|
+
var CALC_TYPES = /* @__PURE__ */ new Set(["length", "percentage", "number", "angle"]);
|
|
2502
|
+
var BOUNDED_TYPES = /* @__PURE__ */ new Set(["number", "number|percentage", "number|keyword"]);
|
|
2300
2503
|
var CALC_CHARACTER = /^[\d.\s+\-*/%a-z,]$/i;
|
|
2301
2504
|
var CUSTOM_PROPERTY_NAME = /^--[\w-]+$/;
|
|
2302
2505
|
function validate(raw, spec) {
|
|
@@ -2312,7 +2515,7 @@ function validate(raw, spec) {
|
|
|
2312
2515
|
return reject(spec, `not a valid ${describeType(spec)}`);
|
|
2313
2516
|
}
|
|
2314
2517
|
function checkKeywordHalf(value, spec) {
|
|
2315
|
-
if (spec.type !== "keyword" && spec.type !== "angle|keyword") return null;
|
|
2518
|
+
if (spec.type !== "keyword" && spec.type !== "angle|keyword" && spec.type !== "number|keyword") return null;
|
|
2316
2519
|
if (spec.keywords?.includes(value)) return { value, ok: true };
|
|
2317
2520
|
if (spec.type !== "keyword") return null;
|
|
2318
2521
|
return reject(spec, `expected one of ${spec.keywords?.join(", ") || "(none declared)"}`);
|
|
@@ -2371,8 +2574,8 @@ function isAcceptable(value, type) {
|
|
|
2371
2574
|
return (value.startsWith("calc(") || value.startsWith("var(")) && nextCalcToken(value, 0, value.length) === value.length;
|
|
2372
2575
|
}
|
|
2373
2576
|
function describeType(spec) {
|
|
2374
|
-
if (spec.type === "angle|keyword") {
|
|
2375
|
-
return
|
|
2577
|
+
if (spec.type === "angle|keyword" || spec.type === "number|keyword") {
|
|
2578
|
+
return `${spec.type.split("|")[0]} or one of ${spec.keywords?.join(", ") || "(none declared)"}`;
|
|
2376
2579
|
}
|
|
2377
2580
|
return spec.type.replace("|", " or ");
|
|
2378
2581
|
}
|
|
@@ -2612,64 +2815,10 @@ function isTargetGroupHost(el) {
|
|
|
2612
2815
|
|
|
2613
2816
|
// src/core/stagger-config.ts
|
|
2614
2817
|
var FROM_KEYWORDS = /* @__PURE__ */ new Set(["start", "end", "center", "edges", "random"]);
|
|
2615
|
-
var ORDER_KEYS = /* @__PURE__ */ new Set(["from", "order"]);
|
|
2616
|
-
var SPREAD_KEY = "spread";
|
|
2617
|
-
var COLS_KEY = "cols";
|
|
2618
|
-
var AXIS_KEYS = /* @__PURE__ */ new Set(["axis", "along"]);
|
|
2619
2818
|
var AXIS_VALUES = /* @__PURE__ */ new Set(["x", "y"]);
|
|
2620
2819
|
var ORIGIN_RE = /^(\d+(?:\.\d+)?|\.\d+)\/(\d+(?:\.\d+)?|\.\d+)$/;
|
|
2621
2820
|
var COLS_RE = /^\d{1,9}$/;
|
|
2622
|
-
var PAIR_RE = /^([a-zA-Z-]+):(.*)$/;
|
|
2623
2821
|
var INDEX_RE = /^-?\d{1,9}$/;
|
|
2624
|
-
function parseStaggerTokens(value, warnings) {
|
|
2625
|
-
const config = { from: "start" };
|
|
2626
|
-
const seen = { from: false, spread: false, cols: false, along: false };
|
|
2627
|
-
for (const token of splitTopLevel(value, " ", warnings)) {
|
|
2628
|
-
const pair = PAIR_RE.exec(token);
|
|
2629
|
-
if (pair) applyStaggerPair(pair[1], pair[2], { config, seen, warnings });
|
|
2630
|
-
else config.step = keepFirstStep(config.step, token, warnings);
|
|
2631
|
-
}
|
|
2632
|
-
return { config, sawFrom: seen.from };
|
|
2633
|
-
}
|
|
2634
|
-
function applyStaggerPair(key, raw, state) {
|
|
2635
|
-
const slot = slotFor(key);
|
|
2636
|
-
if (slot === void 0) {
|
|
2637
|
-
state.warnings.push(
|
|
2638
|
-
`unrecognised key "${key}" in data-kui-stagger \u2014 expected a time step, "spread:", "cols:", "along:", "from:" or "order:"`
|
|
2639
|
-
);
|
|
2640
|
-
return;
|
|
2641
|
-
}
|
|
2642
|
-
if (claim(slot, raw, state, key)) ASSIGN[slot](raw, state, key);
|
|
2643
|
-
}
|
|
2644
|
-
function slotFor(key) {
|
|
2645
|
-
if (key === SPREAD_KEY) return "spread";
|
|
2646
|
-
if (key === COLS_KEY) return "cols";
|
|
2647
|
-
if (AXIS_KEYS.has(key)) return "along";
|
|
2648
|
-
if (ORDER_KEYS.has(key)) return "from";
|
|
2649
|
-
return void 0;
|
|
2650
|
-
}
|
|
2651
|
-
var ASSIGN = {
|
|
2652
|
-
spread: (raw, state) => {
|
|
2653
|
-
state.config.spread = raw.trim();
|
|
2654
|
-
},
|
|
2655
|
-
cols: (raw, state) => {
|
|
2656
|
-
state.config.cols = parseCols(raw, state.warnings);
|
|
2657
|
-
},
|
|
2658
|
-
along: (raw, state, key) => {
|
|
2659
|
-
state.config.along = parseAxis(raw, state.warnings, key);
|
|
2660
|
-
},
|
|
2661
|
-
from: (raw, state, key) => {
|
|
2662
|
-
state.config.from = parseFrom(raw, state.warnings, key);
|
|
2663
|
-
}
|
|
2664
|
-
};
|
|
2665
|
-
function claim(slot, raw, state, spelling) {
|
|
2666
|
-
if (state.seen[slot]) {
|
|
2667
|
-
state.warnings.push(`duplicate "${spelling}:" in data-kui-stagger \u2014 "${raw}" ignored`);
|
|
2668
|
-
return false;
|
|
2669
|
-
}
|
|
2670
|
-
state.seen[slot] = true;
|
|
2671
|
-
return true;
|
|
2672
|
-
}
|
|
2673
2822
|
function parseCols(raw, warnings) {
|
|
2674
2823
|
const value = raw.trim();
|
|
2675
2824
|
if (value === "auto") return "auto";
|
|
@@ -2677,21 +2826,25 @@ function parseCols(raw, warnings) {
|
|
|
2677
2826
|
warnings.push(`unrecognised "cols:${raw}" \u2014 expected a column count or "auto"`);
|
|
2678
2827
|
return void 0;
|
|
2679
2828
|
}
|
|
2680
|
-
function parseAxis(raw, warnings
|
|
2829
|
+
function parseAxis(raw, warnings) {
|
|
2681
2830
|
const value = raw.trim();
|
|
2682
2831
|
if (AXIS_VALUES.has(value)) return value;
|
|
2683
|
-
warnings.push(`unrecognised "
|
|
2832
|
+
warnings.push(`unrecognised "along:${raw}" \u2014 expected x or y`);
|
|
2684
2833
|
return void 0;
|
|
2685
2834
|
}
|
|
2686
|
-
function resolveStaggerConfig(
|
|
2687
|
-
|
|
2688
|
-
if (attribute === null && inline === void 0) return void 0;
|
|
2689
|
-
return resolveStaggerConfigFrom(attribute, inline, warnings);
|
|
2835
|
+
function resolveStaggerConfig(source, warnings = []) {
|
|
2836
|
+
return resolveStaggerConfigFrom(inlineGroupKeys(source), warnings);
|
|
2690
2837
|
}
|
|
2691
|
-
function resolveStaggerConfigFrom(
|
|
2692
|
-
if (
|
|
2693
|
-
const {
|
|
2694
|
-
|
|
2838
|
+
function resolveStaggerConfigFrom(keys, warnings = []) {
|
|
2839
|
+
if (keys === void 0) return void 0;
|
|
2840
|
+
const config = { from: keys.order === void 0 ? "start" : parseFrom(keys.order, warnings) };
|
|
2841
|
+
if (keepValue("step", keys.cascade, warnings)) config.step = keys.cascade;
|
|
2842
|
+
if (keepValue("spread", keys.spread, warnings)) config.spread = keys.spread;
|
|
2843
|
+
const cols = keys.cols === void 0 ? void 0 : parseCols(keys.cols, warnings);
|
|
2844
|
+
if (cols !== void 0) config.cols = cols;
|
|
2845
|
+
const along = keys.along === void 0 ? void 0 : parseAxis(keys.along, warnings);
|
|
2846
|
+
if (along !== void 0) config.along = along;
|
|
2847
|
+
return oneStepMode(config, warnings);
|
|
2695
2848
|
}
|
|
2696
2849
|
function oneStepMode(config, warnings) {
|
|
2697
2850
|
if (config.spread === void 0 || config.step === void 0) return config;
|
|
@@ -2708,48 +2861,12 @@ function inlineGroupKeys(source) {
|
|
|
2708
2861
|
const keys = { cascade, spread, order, cols, along };
|
|
2709
2862
|
return Object.values(keys).some((value) => value !== void 0) ? keys : void 0;
|
|
2710
2863
|
}
|
|
2711
|
-
function screenStep(config, warnings) {
|
|
2712
|
-
const screened = { ...config };
|
|
2713
|
-
if (!keepValue("step", config.step, warnings)) delete screened.step;
|
|
2714
|
-
if (!keepValue("spread", config.spread, warnings)) delete screened.spread;
|
|
2715
|
-
return screened;
|
|
2716
|
-
}
|
|
2717
2864
|
function keepValue(label, value, warnings) {
|
|
2718
2865
|
if (value === void 0) return false;
|
|
2719
2866
|
if (isSafeCssValue(value)) return true;
|
|
2720
2867
|
warnings.push(`stagger ${label} "${value}" contains disallowed CSS syntax \u2014 ignored`);
|
|
2721
2868
|
return false;
|
|
2722
2869
|
}
|
|
2723
|
-
function mergeInline(longhand, sawFrom, inline, warnings) {
|
|
2724
|
-
const config = { ...longhand };
|
|
2725
|
-
if (inline.cascade !== void 0) {
|
|
2726
|
-
warnOverride("stagger step", longhand.step, inline.cascade, warnings);
|
|
2727
|
-
config.step = inline.cascade;
|
|
2728
|
-
}
|
|
2729
|
-
if (inline.spread !== void 0) {
|
|
2730
|
-
warnOverride("stagger budget", longhand.spread, inline.spread, warnings);
|
|
2731
|
-
config.spread = inline.spread;
|
|
2732
|
-
}
|
|
2733
|
-
mergeInlineGrid(config, longhand, inline, warnings);
|
|
2734
|
-
if (inline.order !== void 0) {
|
|
2735
|
-
const order = parseFrom(inline.order, warnings, "order");
|
|
2736
|
-
warnOverride("stagger order", sawFrom ? longhand.from : void 0, order, warnings);
|
|
2737
|
-
config.from = order;
|
|
2738
|
-
}
|
|
2739
|
-
return config;
|
|
2740
|
-
}
|
|
2741
|
-
function mergeInlineGrid(config, longhand, inline, warnings) {
|
|
2742
|
-
if (inline.cols !== void 0) {
|
|
2743
|
-
const cols = parseCols(inline.cols, warnings);
|
|
2744
|
-
warnOverride("stagger columns", longhand.cols, cols, warnings);
|
|
2745
|
-
if (cols !== void 0) config.cols = cols;
|
|
2746
|
-
}
|
|
2747
|
-
if (inline.along !== void 0) {
|
|
2748
|
-
const along = parseAxis(inline.along, warnings, "along");
|
|
2749
|
-
warnOverride("stagger axis", longhand.along, along, warnings);
|
|
2750
|
-
if (along !== void 0) config.along = along;
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
2870
|
function hasGroupKey(source) {
|
|
2754
2871
|
return GROUP_KEY_PREFIXES.some((prefix) => source.includes(prefix));
|
|
2755
2872
|
}
|
|
@@ -2760,25 +2877,14 @@ var GROUP_KEY_PREFIXES = [
|
|
|
2760
2877
|
"cols:",
|
|
2761
2878
|
"along:"
|
|
2762
2879
|
];
|
|
2763
|
-
function
|
|
2764
|
-
if (previous === void 0 || next === void 0 || previous === next) return;
|
|
2765
|
-
warnings.push(
|
|
2766
|
-
`conflicting ${label}: data-kui-stagger says "${String(previous)}", data-kui says "${String(next)}" \u2014 data-kui wins`
|
|
2767
|
-
);
|
|
2768
|
-
}
|
|
2769
|
-
function keepFirstStep(current, token, warnings) {
|
|
2770
|
-
if (current === void 0) return token;
|
|
2771
|
-
warnings.push(`extra token "${token}" in data-kui-stagger (expected one time step)`);
|
|
2772
|
-
return current;
|
|
2773
|
-
}
|
|
2774
|
-
function parseFrom(raw, warnings, key = "from") {
|
|
2880
|
+
function parseFrom(raw, warnings) {
|
|
2775
2881
|
const value = raw.trim();
|
|
2776
2882
|
if (FROM_KEYWORDS.has(value)) return value;
|
|
2777
2883
|
if (INDEX_RE.test(value)) return Number(value);
|
|
2778
2884
|
const origin = ORIGIN_RE.exec(value);
|
|
2779
2885
|
if (origin) return { x: clamp012(Number(origin[1]), value, warnings), y: clamp012(Number(origin[2]), value, warnings) };
|
|
2780
2886
|
warnings.push(
|
|
2781
|
-
`unrecognised "
|
|
2887
|
+
`unrecognised "order:${raw}" \u2014 expected start, end, center, edges, random, a child index, or an "x/y" point in a grid`
|
|
2782
2888
|
);
|
|
2783
2889
|
return "start";
|
|
2784
2890
|
}
|
|
@@ -2877,11 +2983,7 @@ function scatterKey(index, count) {
|
|
|
2877
2983
|
function indexStaggerGroup(group, reporter) {
|
|
2878
2984
|
const warnings = [];
|
|
2879
2985
|
const ledgers = reopenLedger(group);
|
|
2880
|
-
const config = resolveStaggerConfig(
|
|
2881
|
-
group.getAttribute(ATTR.stagger),
|
|
2882
|
-
group.getAttribute(ATTR.source) ?? "",
|
|
2883
|
-
warnings
|
|
2884
|
-
) ?? { from: "start" };
|
|
2986
|
+
const config = resolveStaggerConfig(group.getAttribute(ATTR.source) ?? "", warnings) ?? { from: "start" };
|
|
2885
2987
|
const children = animatedChildren(group);
|
|
2886
2988
|
const ranks = staggerRanks(children.length, config.from, warnings, resolveLayout(config, children, warnings));
|
|
2887
2989
|
let maxRank = 0;
|
|
@@ -2894,9 +2996,30 @@ function indexStaggerGroup(group, reporter) {
|
|
|
2894
2996
|
const step = resolveStep(config, maxRank);
|
|
2895
2997
|
if (step) ledgers.style(group).set("--kui-stagger", step);
|
|
2896
2998
|
ledgers.style(group).set("--kui-stagger-count", String(round2(maxRank + 1)));
|
|
2999
|
+
indexNestedStagger(group, { children, ranks, maxRank, ledgers }, reporter);
|
|
2897
3000
|
for (const warning of warnings) reporter?.warn(warning, group);
|
|
2898
3001
|
}
|
|
2899
3002
|
var GROUP_LEDGERS = /* @__PURE__ */ new WeakMap();
|
|
3003
|
+
var NESTED_STAGGER = /* @__PURE__ */ new WeakMap();
|
|
3004
|
+
function indexNestedStagger(group, { children, ranks, maxRank, ledgers }, reporter) {
|
|
3005
|
+
const inherited = NESTED_STAGGER.get(group);
|
|
3006
|
+
const outer = GROUP_LEDGERS.get(group.parentElement) === inherited?.owner ? inherited : void 0;
|
|
3007
|
+
const [base, outerSpan, depth] = outer ? [outer.offset, outer.span, outer.depth + 1] : ["0ms", "0ms", 0];
|
|
3008
|
+
const step = `--kui-stagger-step-${depth}`;
|
|
3009
|
+
const span = `calc(${outerSpan} + ${maxRank} * var(${step}))`;
|
|
3010
|
+
const nestedGroups = new Set([...group.children].filter(declaresGroup));
|
|
3011
|
+
if (!outer && !nestedGroups.size) return;
|
|
3012
|
+
ledgers.style(group).set(step, "var(--kui-stagger, 0ms)");
|
|
3013
|
+
for (const [index, child] of children.entries()) {
|
|
3014
|
+
const nested = nestedGroups.has(child);
|
|
3015
|
+
if (!outer && !nested) continue;
|
|
3016
|
+
const offset = `calc(${base} + ${ranks[index]} * var(${step}))`;
|
|
3017
|
+
ledgers.style(child).set("--kui-stagger-offset", offset);
|
|
3018
|
+
ledgers.style(child).set("--kui-stagger-span", span);
|
|
3019
|
+
NESTED_STAGGER.set(child, { owner: ledgers, depth, offset, span });
|
|
3020
|
+
}
|
|
3021
|
+
for (const nested of nestedGroups) indexStaggerGroup(nested, reporter);
|
|
3022
|
+
}
|
|
2900
3023
|
var GROUP_OF_CHILD = /* @__PURE__ */ new WeakMap();
|
|
2901
3024
|
function restageAfterRemoval(removed, reporter) {
|
|
2902
3025
|
const groups = /* @__PURE__ */ new Set();
|
|
@@ -2904,7 +3027,7 @@ function restageAfterRemoval(removed, reporter) {
|
|
|
2904
3027
|
const group = GROUP_OF_CHILD.get(el);
|
|
2905
3028
|
if (group) groups.add(group);
|
|
2906
3029
|
}
|
|
2907
|
-
for (const group of groups)
|
|
3030
|
+
for (const group of groups) restageOne(group, reporter);
|
|
2908
3031
|
}
|
|
2909
3032
|
function reopenLedger(group) {
|
|
2910
3033
|
GROUP_LEDGERS.get(group)?.restore();
|
|
@@ -2917,28 +3040,36 @@ function releaseStaggerGroup(group) {
|
|
|
2917
3040
|
GROUP_LEDGERS.delete(group);
|
|
2918
3041
|
}
|
|
2919
3042
|
function releaseStagger(root) {
|
|
2920
|
-
const selector = `[${ATTR.
|
|
3043
|
+
const selector = `[${ATTR.source}]`;
|
|
2921
3044
|
if (root instanceof Element && root.matches(selector)) releaseStaggerGroup(root);
|
|
2922
3045
|
for (const el of root.querySelectorAll(selector)) releaseStaggerGroup(el);
|
|
2923
3046
|
}
|
|
2924
3047
|
function restageAround(el, reporter) {
|
|
2925
|
-
restageOne(el, reporter);
|
|
2926
3048
|
const parent = el.parentElement;
|
|
3049
|
+
const parentIsGroup = parent !== null && declaresGroup(parent);
|
|
2927
3050
|
if (parent) restageOne(parent, reporter);
|
|
3051
|
+
if (declaresGroup(el)) {
|
|
3052
|
+
if (!parentIsGroup) indexStaggerGroup(el, reporter);
|
|
3053
|
+
return;
|
|
3054
|
+
}
|
|
3055
|
+
releaseStaggerGroup(el);
|
|
3056
|
+
const nested = [...el.children].filter((child) => NESTED_STAGGER.has(child) && declaresGroup(child));
|
|
3057
|
+
for (const child of nested) indexStaggerGroup(child, reporter);
|
|
2928
3058
|
}
|
|
2929
3059
|
function restageOne(el, reporter) {
|
|
2930
3060
|
if (declaresGroup(el)) indexStaggerGroup(el, reporter);
|
|
2931
3061
|
else releaseStaggerGroup(el);
|
|
2932
3062
|
}
|
|
2933
3063
|
function indexTargetGroup(request) {
|
|
2934
|
-
const { host, matches, styleOf, keys, reporter } = request;
|
|
3064
|
+
const { host, splitLayer, matches, styleOf, keys, reporter } = request;
|
|
2935
3065
|
const warnings = [];
|
|
2936
|
-
const
|
|
2937
|
-
const
|
|
2938
|
-
const maxRank = rankBuckets(
|
|
3066
|
+
const config = (keys ? resolveStaggerConfigFrom(keys, warnings) : resolveStaggerConfig(host.getAttribute(ATTR.source) ?? "", warnings)) ?? { from: "start" };
|
|
3067
|
+
const buckets = splitLayer || config.cols === void 0 ? [matches] : bucketByParent(matches).values();
|
|
3068
|
+
const maxRank = rankBuckets(buckets, config, styleOf, warnings);
|
|
3069
|
+
const timing = styleOf(splitLayer ?? host);
|
|
2939
3070
|
const step = resolveStep(config, maxRank);
|
|
2940
|
-
if (step)
|
|
2941
|
-
|
|
3071
|
+
if (step) timing.set("--kui-stagger", step);
|
|
3072
|
+
timing.set("--kui-stagger-count", String(round2(maxRank + 1)));
|
|
2942
3073
|
for (const warning of warnings) reporter?.warn(warning, host);
|
|
2943
3074
|
}
|
|
2944
3075
|
function bucketByParent(matches) {
|
|
@@ -2950,9 +3081,9 @@ function bucketByParent(matches) {
|
|
|
2950
3081
|
}
|
|
2951
3082
|
return byParent;
|
|
2952
3083
|
}
|
|
2953
|
-
function rankBuckets(
|
|
3084
|
+
function rankBuckets(buckets, config, styleOf, warnings) {
|
|
2954
3085
|
let maxRank = 0;
|
|
2955
|
-
for (const siblings of
|
|
3086
|
+
for (const siblings of buckets) {
|
|
2956
3087
|
const layout = resolveLayout(config, siblings, warnings);
|
|
2957
3088
|
const ranks = staggerRanks(siblings.length, config.from, warnings, layout);
|
|
2958
3089
|
for (const [index, match] of siblings.entries()) {
|
|
@@ -3003,101 +3134,409 @@ function measureColumns(members, warnings) {
|
|
|
3003
3134
|
function animatedChildren(group) {
|
|
3004
3135
|
const children = [];
|
|
3005
3136
|
for (const child of group.children) {
|
|
3006
|
-
|
|
3137
|
+
const source = child.getAttribute(ATTR.source);
|
|
3138
|
+
if (source === null || hasGroupKey(source) && isGroupOnly(parse(source))) continue;
|
|
3139
|
+
children.push(child);
|
|
3007
3140
|
}
|
|
3008
3141
|
return children;
|
|
3009
3142
|
}
|
|
3010
3143
|
function applyStagger(root, reporter) {
|
|
3011
|
-
const selector = `[${ATTR.
|
|
3144
|
+
const selector = `[${ATTR.source}]`;
|
|
3012
3145
|
if (root instanceof Element && root.matches(selector)) restageOne(root, reporter);
|
|
3013
|
-
for (const group of root.querySelectorAll(selector))
|
|
3146
|
+
for (const group of root.querySelectorAll(selector)) {
|
|
3147
|
+
const parent = group.parentElement;
|
|
3148
|
+
if (parent && root.contains(parent) && declaresGroup(parent) && declaresGroup(group)) continue;
|
|
3149
|
+
restageOne(group, reporter);
|
|
3150
|
+
}
|
|
3014
3151
|
}
|
|
3015
3152
|
function declaresGroup(el) {
|
|
3016
3153
|
if (el.hasAttribute(ATTR.define)) return false;
|
|
3017
3154
|
if (isTargetGroupHost(el)) return false;
|
|
3018
|
-
|
|
3019
|
-
return resolveStaggerConfig(null, el.getAttribute(ATTR.source) ?? "") !== void 0;
|
|
3155
|
+
return resolveStaggerConfig(el.getAttribute(ATTR.source) ?? "") !== void 0;
|
|
3020
3156
|
}
|
|
3021
3157
|
|
|
3022
|
-
// src/core/
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
return {
|
|
3032
|
-
requestFrame: (callback) => raf(callback),
|
|
3033
|
-
cancelFrame: (handle) => globalThis.cancelAnimationFrame(handle)
|
|
3034
|
-
};
|
|
3158
|
+
// src/core/time-scale.ts
|
|
3159
|
+
var TIME_SCALE_ATTR = "data-kui-time-scale";
|
|
3160
|
+
function timeScaleOf(el) {
|
|
3161
|
+
const host = el.closest(`[${TIME_SCALE_ATTR}]`);
|
|
3162
|
+
const value = host?.getAttribute(TIME_SCALE_ATTR)?.trim();
|
|
3163
|
+
if (!value) return 1;
|
|
3164
|
+
const parsed = Number(value);
|
|
3165
|
+
if (!Number.isFinite(parsed)) return 1;
|
|
3166
|
+
return Math.min(4, Math.max(0.05, parsed));
|
|
3035
3167
|
}
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
function
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3168
|
+
|
|
3169
|
+
// src/core/instances.ts
|
|
3170
|
+
function animationsOf(el) {
|
|
3171
|
+
const getAnimations = el.getAnimations;
|
|
3172
|
+
return typeof getAnimations === "function" ? getAnimations.call(el) : [];
|
|
3173
|
+
}
|
|
3174
|
+
function ownedAnimationsOf(el, names) {
|
|
3175
|
+
return animationsOf(el).filter((animation) => {
|
|
3176
|
+
const name = animation.animationName;
|
|
3177
|
+
return typeof name === "string" && names.has(name);
|
|
3178
|
+
});
|
|
3179
|
+
}
|
|
3180
|
+
function flushComputedAnimationName(el) {
|
|
3181
|
+
return getComputedStyle(el).animationName;
|
|
3182
|
+
}
|
|
3183
|
+
function restartCssAnimation(el, ledger) {
|
|
3184
|
+
const name = el.style.getPropertyValue("animation-name");
|
|
3185
|
+
ledger.set("animation-name", "none");
|
|
3186
|
+
flushComputedAnimationName(el);
|
|
3187
|
+
ledger.set("animation-name", name);
|
|
3188
|
+
}
|
|
3189
|
+
function watchCompletion(animations, settle) {
|
|
3190
|
+
if (animations.length === 0) {
|
|
3191
|
+
settle();
|
|
3192
|
+
return;
|
|
3045
3193
|
}
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3194
|
+
void Promise.all(animations.map((a) => a.finished.catch(() => void 0))).then(() => settle());
|
|
3195
|
+
}
|
|
3196
|
+
function startCssAnimations(el, ledger, ownedNames, restart) {
|
|
3197
|
+
if (restart) {
|
|
3198
|
+
restartCssAnimation(el, ledger);
|
|
3199
|
+
ledger.set("animation-play-state", "running");
|
|
3200
|
+
const animations2 = ownedAnimationsOf(el, ownedNames);
|
|
3201
|
+
const scale = timeScaleOf(el);
|
|
3202
|
+
if (scale !== 1) {
|
|
3203
|
+
for (const animation of animations2) animation.playbackRate = scale;
|
|
3053
3204
|
}
|
|
3205
|
+
return animations2;
|
|
3054
3206
|
}
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
const
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
root.onResize(() => {
|
|
3062
|
-
epoch++;
|
|
3063
|
-
schedule();
|
|
3064
|
-
})
|
|
3065
|
-
);
|
|
3066
|
-
entries.set(root.key, entry);
|
|
3067
|
-
return entry;
|
|
3207
|
+
const animations = ownedAnimationsOf(el, ownedNames);
|
|
3208
|
+
const stale = animations.filter((animation) => animation.playState === "finished");
|
|
3209
|
+
if (stale.length > 0) {
|
|
3210
|
+
for (const animation of stale) animation.reverse();
|
|
3211
|
+
} else {
|
|
3212
|
+
ledger.set("animation-play-state", "running");
|
|
3068
3213
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3214
|
+
return animations;
|
|
3215
|
+
}
|
|
3216
|
+
function createCssInstance(el, ledger, animationNames, mode = false, repeatDelays) {
|
|
3217
|
+
const scrubbed = mode === true;
|
|
3218
|
+
const ownedNames = new Set(animationNames);
|
|
3219
|
+
let settle;
|
|
3220
|
+
let finished = new Promise((resolve) => {
|
|
3221
|
+
settle = resolve;
|
|
3222
|
+
});
|
|
3223
|
+
let activatedBefore = false;
|
|
3224
|
+
const watch = (animations) => watchCompletion(animations, () => settle?.());
|
|
3225
|
+
const gaps = repeatDelays && { tracks: repeatDelays, timed: /* @__PURE__ */ new WeakSet() };
|
|
3226
|
+
function applyRepeatDelays(animations) {
|
|
3227
|
+
if (!gaps || animations.every((animation) => gaps.timed.has(animation))) return;
|
|
3228
|
+
const names = flushComputedAnimationName(el).split(",").map((name) => name.trim());
|
|
3229
|
+
const indices = /* @__PURE__ */ new Map();
|
|
3230
|
+
for (const animation of animations) {
|
|
3231
|
+
const name = animation.animationName;
|
|
3232
|
+
const index = names.indexOf(name, indices.get(name) ?? 0);
|
|
3233
|
+
indices.set(name, index + 1);
|
|
3234
|
+
const gap = gaps.tracks.get(index);
|
|
3235
|
+
if (gap === void 0 || gaps.timed.has(animation)) continue;
|
|
3236
|
+
const effect = animation.effect;
|
|
3237
|
+
if (!effect) continue;
|
|
3238
|
+
const { duration, iterations, direction } = effect.getTiming();
|
|
3239
|
+
if (typeof duration !== "number" || iterations <= 1) continue;
|
|
3240
|
+
const cycle = duration + gap;
|
|
3241
|
+
const lead = Number(direction === "alternate") * (gap / 2);
|
|
3242
|
+
effect.updateTiming({
|
|
3243
|
+
duration: cycle,
|
|
3244
|
+
iterationStart: lead / cycle,
|
|
3245
|
+
iterations: iterations - gap / cycle,
|
|
3246
|
+
easing: `linear(0 0% ${100 * (lead / cycle)}%, 1 ${100 * ((lead + duration) / cycle)}% 100%)`
|
|
3247
|
+
});
|
|
3248
|
+
gaps.timed.add(animation);
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
if (gaps) applyRepeatDelays(ownedAnimationsOf(el, ownedNames));
|
|
3252
|
+
function drive(rate) {
|
|
3253
|
+
if (scrubbed) return;
|
|
3254
|
+
const animations = ownedAnimationsOf(el, ownedNames);
|
|
3255
|
+
finished = new Promise((resolve) => {
|
|
3256
|
+
settle = resolve;
|
|
3257
|
+
});
|
|
3258
|
+
for (const animation of animations) {
|
|
3259
|
+
animation.playbackRate = rate * timeScaleOf(el);
|
|
3260
|
+
animation.play();
|
|
3261
|
+
}
|
|
3262
|
+
ledger.set("animation-play-state", "running");
|
|
3263
|
+
watch(animations);
|
|
3073
3264
|
}
|
|
3074
3265
|
return {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3266
|
+
// Attached unconditionally, including for a scrubbed instance. Whether control is *allowed*
|
|
3267
|
+
// here is a policy question about the element's timeline, not a capability question about this
|
|
3268
|
+
// instance — a scrubbed animation has a perfectly real playhead, it just belongs to the
|
|
3269
|
+
// scroller. Keeping that decision in one place (`InstanceState.progressDriven`, read by
|
|
3270
|
+
// `control.ts`) beats splitting it across both files and letting them drift.
|
|
3271
|
+
control: createCssControl(() => ownedAnimationsOf(el, ownedNames), ledger),
|
|
3272
|
+
activate() {
|
|
3273
|
+
finished = new Promise((resolve) => {
|
|
3274
|
+
settle = resolve;
|
|
3275
|
+
});
|
|
3276
|
+
if (scrubbed) {
|
|
3277
|
+
settle?.();
|
|
3278
|
+
return;
|
|
3279
|
+
}
|
|
3280
|
+
const animations = startCssAnimations(el, ledger, ownedNames, !activatedBefore || mode === "restart");
|
|
3281
|
+
applyRepeatDelays(animations);
|
|
3282
|
+
activatedBefore = true;
|
|
3283
|
+
watch(animations);
|
|
3083
3284
|
},
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3285
|
+
play() {
|
|
3286
|
+
drive(1);
|
|
3287
|
+
},
|
|
3288
|
+
reverse() {
|
|
3289
|
+
drive(-1);
|
|
3290
|
+
},
|
|
3291
|
+
cancel() {
|
|
3292
|
+
for (const animation of ownedAnimationsOf(el, ownedNames)) animation.cancel();
|
|
3293
|
+
settle?.();
|
|
3294
|
+
},
|
|
3295
|
+
finish() {
|
|
3296
|
+
for (const animation of ownedAnimationsOf(el, ownedNames)) animation.finish();
|
|
3297
|
+
settle?.();
|
|
3298
|
+
},
|
|
3299
|
+
get finished() {
|
|
3300
|
+
return finished;
|
|
3087
3301
|
},
|
|
3088
|
-
rootCount: () => entries.size,
|
|
3089
3302
|
destroy() {
|
|
3090
|
-
|
|
3091
|
-
pending = null;
|
|
3092
|
-
for (const entry of entries.values()) {
|
|
3093
|
-
entry.subscribers.clear();
|
|
3094
|
-
for (const detach of entry.detach) detach();
|
|
3095
|
-
}
|
|
3096
|
-
entries.clear();
|
|
3303
|
+
settle?.();
|
|
3097
3304
|
}
|
|
3098
3305
|
};
|
|
3099
3306
|
}
|
|
3100
|
-
function
|
|
3307
|
+
function continuousSetup(cleanup) {
|
|
3308
|
+
return { cleanup, continuous: true };
|
|
3309
|
+
}
|
|
3310
|
+
function cleanupOf(result) {
|
|
3311
|
+
if (result === void 0) return void 0;
|
|
3312
|
+
return typeof result === "function" ? result : result.cleanup;
|
|
3313
|
+
}
|
|
3314
|
+
function deferredInstance(setup) {
|
|
3315
|
+
let running;
|
|
3316
|
+
let settle;
|
|
3317
|
+
let finished = Promise.resolve();
|
|
3318
|
+
let finite = false;
|
|
3319
|
+
const teardown = () => {
|
|
3320
|
+
cleanupOf(running)?.();
|
|
3321
|
+
running = void 0;
|
|
3322
|
+
settle?.();
|
|
3323
|
+
};
|
|
3324
|
+
return createJsInstance({
|
|
3325
|
+
activate() {
|
|
3326
|
+
if (running !== void 0) teardown();
|
|
3327
|
+
running = setup();
|
|
3328
|
+
finite = typeof running === "object" && "finished" in running;
|
|
3329
|
+
if (typeof running === "function" || "continuous" in running) return;
|
|
3330
|
+
const work = running.finished;
|
|
3331
|
+
finished = new Promise((resolve2) => {
|
|
3332
|
+
settle = resolve2;
|
|
3333
|
+
});
|
|
3334
|
+
const resolve = settle;
|
|
3335
|
+
void work.then(() => resolve?.());
|
|
3336
|
+
},
|
|
3337
|
+
cancel: teardown,
|
|
3338
|
+
finish() {
|
|
3339
|
+
if (typeof running === "object" && "finish" in running) running.finish?.();
|
|
3340
|
+
settle?.();
|
|
3341
|
+
},
|
|
3342
|
+
destroy: teardown,
|
|
3343
|
+
finished: () => finished,
|
|
3344
|
+
// Only an explicit marker counts. A bare `Cleanup` deliberately does not — see
|
|
3345
|
+
// `ContinuousSetup` above for why the two cannot be told apart by shape.
|
|
3346
|
+
continuous: () => typeof running === "object" && "continuous" in running,
|
|
3347
|
+
finite: () => finite
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
function deferPrepare(setup) {
|
|
3351
|
+
return (...args) => deferredInstance(() => setup(...args));
|
|
3352
|
+
}
|
|
3353
|
+
function createJsInstance(hooks) {
|
|
3354
|
+
let active = false;
|
|
3355
|
+
let run = 0;
|
|
3356
|
+
return {
|
|
3357
|
+
activate() {
|
|
3358
|
+
if (active) return;
|
|
3359
|
+
hooks.activate();
|
|
3360
|
+
active = true;
|
|
3361
|
+
const id = ++run;
|
|
3362
|
+
if (hooks.continuous?.()) return;
|
|
3363
|
+
void (hooks.finished?.() ?? Promise.resolve()).then(() => {
|
|
3364
|
+
if (id === run) active = false;
|
|
3365
|
+
});
|
|
3366
|
+
},
|
|
3367
|
+
cancel() {
|
|
3368
|
+
hooks.cancel?.();
|
|
3369
|
+
active = false;
|
|
3370
|
+
},
|
|
3371
|
+
finish() {
|
|
3372
|
+
hooks.finish?.();
|
|
3373
|
+
},
|
|
3374
|
+
get finished() {
|
|
3375
|
+
return hooks.finished?.() ?? Promise.resolve();
|
|
3376
|
+
},
|
|
3377
|
+
get continuous() {
|
|
3378
|
+
return hooks.continuous?.() ?? false;
|
|
3379
|
+
},
|
|
3380
|
+
get finite() {
|
|
3381
|
+
return hooks.finite?.();
|
|
3382
|
+
},
|
|
3383
|
+
destroy() {
|
|
3384
|
+
active = false;
|
|
3385
|
+
hooks.destroy();
|
|
3386
|
+
}
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
function nextFrame(win, fn) {
|
|
3390
|
+
if (typeof win.requestAnimationFrame === "function") {
|
|
3391
|
+
const id2 = win.requestAnimationFrame(fn);
|
|
3392
|
+
return { cancel: () => win.cancelAnimationFrame?.(id2) };
|
|
3393
|
+
}
|
|
3394
|
+
const id = setTimeout(fn, 16);
|
|
3395
|
+
return { cancel: () => clearTimeout(id) };
|
|
3396
|
+
}
|
|
3397
|
+
function repeatedInstance(inner, repeat, win) {
|
|
3398
|
+
const total = isInfiniteRepeat(repeat) ? Infinity : Number(repeat);
|
|
3399
|
+
let generation = 0;
|
|
3400
|
+
let stopped = true;
|
|
3401
|
+
let pending;
|
|
3402
|
+
let finished = Promise.resolve();
|
|
3403
|
+
let settle;
|
|
3404
|
+
const halt = () => {
|
|
3405
|
+
generation++;
|
|
3406
|
+
pending?.cancel();
|
|
3407
|
+
pending = void 0;
|
|
3408
|
+
};
|
|
3409
|
+
const stop = () => {
|
|
3410
|
+
stopped = true;
|
|
3411
|
+
halt();
|
|
3412
|
+
settle?.();
|
|
3413
|
+
};
|
|
3414
|
+
const run = (done, gen) => {
|
|
3415
|
+
inner.activate();
|
|
3416
|
+
void inner.finished.then(() => {
|
|
3417
|
+
if (gen !== generation || stopped) return;
|
|
3418
|
+
if (inner.finite !== true || done + 1 >= total) return stop();
|
|
3419
|
+
pending = nextFrame(win, () => {
|
|
3420
|
+
pending = void 0;
|
|
3421
|
+
if (gen === generation && !stopped) run(done + 1, gen);
|
|
3422
|
+
});
|
|
3423
|
+
});
|
|
3424
|
+
};
|
|
3425
|
+
return {
|
|
3426
|
+
activate() {
|
|
3427
|
+
halt();
|
|
3428
|
+
if (!stopped) inner.cancel();
|
|
3429
|
+
settle?.();
|
|
3430
|
+
stopped = false;
|
|
3431
|
+
finished = new Promise((resolve) => {
|
|
3432
|
+
settle = resolve;
|
|
3433
|
+
});
|
|
3434
|
+
run(0, generation);
|
|
3435
|
+
},
|
|
3436
|
+
cancel: () => {
|
|
3437
|
+
stop();
|
|
3438
|
+
inner.cancel();
|
|
3439
|
+
},
|
|
3440
|
+
finish: () => {
|
|
3441
|
+
stop();
|
|
3442
|
+
inner.finish();
|
|
3443
|
+
},
|
|
3444
|
+
destroy: () => {
|
|
3445
|
+
stop();
|
|
3446
|
+
inner.destroy();
|
|
3447
|
+
},
|
|
3448
|
+
get finished() {
|
|
3449
|
+
return finished;
|
|
3450
|
+
},
|
|
3451
|
+
get continuous() {
|
|
3452
|
+
return inner.continuous;
|
|
3453
|
+
},
|
|
3454
|
+
get finite() {
|
|
3455
|
+
return inner.finite;
|
|
3456
|
+
},
|
|
3457
|
+
replaceOnActivate: inner.replaceOnActivate
|
|
3458
|
+
};
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
// src/core/scroll-scheduler.ts
|
|
3462
|
+
function defaultDeps() {
|
|
3463
|
+
const raf = globalThis.requestAnimationFrame;
|
|
3464
|
+
if (typeof raf !== "function") {
|
|
3465
|
+
return {
|
|
3466
|
+
requestFrame: (callback) => globalThis.setTimeout(callback, 16),
|
|
3467
|
+
cancelFrame: (handle) => globalThis.clearTimeout(handle)
|
|
3468
|
+
};
|
|
3469
|
+
}
|
|
3470
|
+
return {
|
|
3471
|
+
requestFrame: (callback) => raf(callback),
|
|
3472
|
+
cancelFrame: (handle) => globalThis.cancelAnimationFrame(handle)
|
|
3473
|
+
};
|
|
3474
|
+
}
|
|
3475
|
+
function createScrollScheduler(deps = defaultDeps()) {
|
|
3476
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3477
|
+
let epoch = 0;
|
|
3478
|
+
let pending = null;
|
|
3479
|
+
function schedule(entry) {
|
|
3480
|
+
if (entry) entry.dirty = true;
|
|
3481
|
+
else for (const other of entries.values()) other.dirty = true;
|
|
3482
|
+
if (pending !== null) return;
|
|
3483
|
+
pending = deps.requestFrame(runFrame);
|
|
3484
|
+
}
|
|
3485
|
+
function runFrame() {
|
|
3486
|
+
pending = null;
|
|
3487
|
+
for (const entry of entries.values()) {
|
|
3488
|
+
if (!entry.dirty || entry.subscribers.size === 0) continue;
|
|
3489
|
+
entry.dirty = false;
|
|
3490
|
+
const frame = { metrics: entry.root.metrics(), epoch };
|
|
3491
|
+
for (const subscriber of [...entry.subscribers]) subscriber(frame);
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
function attach(root) {
|
|
3495
|
+
const existing = entries.get(root.key);
|
|
3496
|
+
if (existing) return existing;
|
|
3497
|
+
const entry = { root, subscribers: /* @__PURE__ */ new Set(), detach: [], dirty: false };
|
|
3498
|
+
entry.detach.push(root.onScroll(() => schedule(entry)));
|
|
3499
|
+
entry.detach.push(
|
|
3500
|
+
root.onResize(() => {
|
|
3501
|
+
epoch++;
|
|
3502
|
+
schedule();
|
|
3503
|
+
})
|
|
3504
|
+
);
|
|
3505
|
+
entries.set(root.key, entry);
|
|
3506
|
+
return entry;
|
|
3507
|
+
}
|
|
3508
|
+
function release(entry) {
|
|
3509
|
+
if (entry.subscribers.size > 0) return;
|
|
3510
|
+
for (const detach of entry.detach) detach();
|
|
3511
|
+
entries.delete(entry.root.key);
|
|
3512
|
+
}
|
|
3513
|
+
return {
|
|
3514
|
+
subscribe(root, onFrame) {
|
|
3515
|
+
const entry = attach(root);
|
|
3516
|
+
entry.subscribers.add(onFrame);
|
|
3517
|
+
schedule(entry);
|
|
3518
|
+
return () => {
|
|
3519
|
+
entry.subscribers.delete(onFrame);
|
|
3520
|
+
release(entry);
|
|
3521
|
+
};
|
|
3522
|
+
},
|
|
3523
|
+
invalidate() {
|
|
3524
|
+
epoch++;
|
|
3525
|
+
schedule();
|
|
3526
|
+
},
|
|
3527
|
+
rootCount: () => entries.size,
|
|
3528
|
+
destroy() {
|
|
3529
|
+
if (pending !== null) deps.cancelFrame(pending);
|
|
3530
|
+
pending = null;
|
|
3531
|
+
for (const entry of entries.values()) {
|
|
3532
|
+
entry.subscribers.clear();
|
|
3533
|
+
for (const detach of entry.detach) detach();
|
|
3534
|
+
}
|
|
3535
|
+
entries.clear();
|
|
3536
|
+
}
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
function windowScrollRoot(win) {
|
|
3101
3540
|
return {
|
|
3102
3541
|
key: "window",
|
|
3103
3542
|
metrics: () => ({
|
|
@@ -3221,199 +3660,224 @@ function createMeasureCache(measure) {
|
|
|
3221
3660
|
};
|
|
3222
3661
|
}
|
|
3223
3662
|
|
|
3224
|
-
// src/core/
|
|
3225
|
-
var
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3663
|
+
// src/core/pause-scope.ts
|
|
3664
|
+
var PAUSE_SCOPE_ATTR = "data-kui-paused";
|
|
3665
|
+
var PAUSE_SCOPE_EVENT = "kui:pausescope";
|
|
3666
|
+
function isPausedByScope(el) {
|
|
3667
|
+
return el.closest(`[${PAUSE_SCOPE_ATTR}]`) !== null;
|
|
3668
|
+
}
|
|
3669
|
+
function announcePauseScope(doc, source) {
|
|
3670
|
+
const Ctor = doc.defaultView?.CustomEvent ?? CustomEvent;
|
|
3671
|
+
const target = source.isConnected ? source : doc;
|
|
3672
|
+
target.dispatchEvent(new Ctor(PAUSE_SCOPE_EVENT, { bubbles: true }));
|
|
3673
|
+
}
|
|
3674
|
+
function watchPauseScope(el, doc, onChange) {
|
|
3675
|
+
let last = isPausedByScope(el);
|
|
3676
|
+
const listener = () => {
|
|
3677
|
+
const now = isPausedByScope(el);
|
|
3678
|
+
if (now === last) return;
|
|
3679
|
+
last = now;
|
|
3680
|
+
onChange(now);
|
|
3681
|
+
};
|
|
3682
|
+
doc.addEventListener(PAUSE_SCOPE_EVENT, listener);
|
|
3683
|
+
return () => doc.removeEventListener(PAUSE_SCOPE_EVENT, listener);
|
|
3233
3684
|
}
|
|
3234
3685
|
|
|
3235
|
-
// src/core/
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
flushComputedAnimationName(el);
|
|
3253
|
-
ledger.set("animation-name", name);
|
|
3254
|
-
}
|
|
3255
|
-
function watchCompletion(animations, settle) {
|
|
3256
|
-
if (animations.length === 0) {
|
|
3257
|
-
settle();
|
|
3258
|
-
return;
|
|
3686
|
+
// src/core/auto-motion.ts
|
|
3687
|
+
var MIN_PERIOD_MS = 2e3;
|
|
3688
|
+
var MAX_FRAME_MS = 100;
|
|
3689
|
+
function clampPeriod(ms) {
|
|
3690
|
+
if (!Number.isFinite(ms) || ms === 0) return 0;
|
|
3691
|
+
return Math.sign(ms) * Math.max(MIN_PERIOD_MS, Math.abs(ms));
|
|
3692
|
+
}
|
|
3693
|
+
function cyclesFor(dtMs, periodMs) {
|
|
3694
|
+
return Math.min(Math.max(dtMs, 0), MAX_FRAME_MS) / periodMs;
|
|
3695
|
+
}
|
|
3696
|
+
function isKeyboardFocus(target) {
|
|
3697
|
+
const node = target;
|
|
3698
|
+
if (typeof node?.matches !== "function") return true;
|
|
3699
|
+
try {
|
|
3700
|
+
return node.matches(":focus-visible");
|
|
3701
|
+
} catch {
|
|
3702
|
+
return true;
|
|
3259
3703
|
}
|
|
3260
|
-
void Promise.all(animations.map((a) => a.finished.catch(() => void 0))).then(() => settle());
|
|
3261
3704
|
}
|
|
3262
|
-
function
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
ledger.set("animation-play-state", "running");
|
|
3705
|
+
function createAutoMotion(request) {
|
|
3706
|
+
const { el, ctx, spinMs, autoplayMs, settleMs, advance, step, setSpinning, onPausedChange } = request;
|
|
3707
|
+
const pauseOnHover = request.pauseOnHover ?? true;
|
|
3708
|
+
const enabled = spinMs !== 0 || autoplayMs !== 0;
|
|
3709
|
+
if (!enabled) {
|
|
3710
|
+
return {
|
|
3711
|
+
enabled,
|
|
3712
|
+
interrupt() {
|
|
3713
|
+
},
|
|
3714
|
+
hold() {
|
|
3715
|
+
},
|
|
3716
|
+
toggle() {
|
|
3717
|
+
},
|
|
3718
|
+
release() {
|
|
3719
|
+
}
|
|
3720
|
+
};
|
|
3279
3721
|
}
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
let
|
|
3285
|
-
let
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
let
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3722
|
+
const win = ctx.win;
|
|
3723
|
+
request.onAutoplayProgress?.(0);
|
|
3724
|
+
let userPaused = ctx.reducedMotion || request.startPaused === true;
|
|
3725
|
+
let hovered = false;
|
|
3726
|
+
let focused = false;
|
|
3727
|
+
let onscreen = true;
|
|
3728
|
+
let gesture = false;
|
|
3729
|
+
let held = false;
|
|
3730
|
+
let scopePaused = isPausedByScope(el);
|
|
3731
|
+
let viewing = false;
|
|
3732
|
+
let viewerOpen = false;
|
|
3733
|
+
let focusBeforeViewer = false;
|
|
3734
|
+
let frame = 0;
|
|
3735
|
+
let lastFrameAt = null;
|
|
3736
|
+
let timer = null;
|
|
3737
|
+
let holdTimer = null;
|
|
3738
|
+
let spinning = false;
|
|
3739
|
+
const active = () => !userPaused && !hovered && !focused && onscreen && !gesture && !held && !viewing && !scopePaused && !ctx.doc.hidden;
|
|
3740
|
+
const requestFrame = (callback) => typeof win.requestAnimationFrame === "function" ? win.requestAnimationFrame(callback) : win.setTimeout(() => callback(Date.now()), 16);
|
|
3741
|
+
const cancelFrame = (handle) => {
|
|
3742
|
+
if (typeof win.cancelAnimationFrame === "function") win.cancelAnimationFrame(handle);
|
|
3743
|
+
else win.clearTimeout(handle);
|
|
3744
|
+
};
|
|
3745
|
+
const publishSpinning = (next) => {
|
|
3746
|
+
if (next === spinning) return;
|
|
3747
|
+
spinning = next;
|
|
3748
|
+
setSpinning(next);
|
|
3749
|
+
};
|
|
3750
|
+
const tick = (now) => {
|
|
3751
|
+
frame = 0;
|
|
3752
|
+
if (!active()) return;
|
|
3753
|
+
if (lastFrameAt !== null) advance(cyclesFor(now - lastFrameAt, spinMs));
|
|
3754
|
+
lastFrameAt = now;
|
|
3755
|
+
frame = requestFrame(tick);
|
|
3756
|
+
};
|
|
3757
|
+
const startSpin = () => {
|
|
3758
|
+
if (frame !== 0) return;
|
|
3759
|
+
publishSpinning(true);
|
|
3760
|
+
lastFrameAt = null;
|
|
3761
|
+
frame = requestFrame(tick);
|
|
3762
|
+
};
|
|
3763
|
+
const stopSpin = () => {
|
|
3764
|
+
if (frame !== 0) cancelFrame(frame);
|
|
3765
|
+
frame = 0;
|
|
3766
|
+
publishSpinning(false);
|
|
3767
|
+
};
|
|
3768
|
+
const armAutoplay = () => {
|
|
3769
|
+
if (timer !== null) return;
|
|
3770
|
+
timer = win.setTimeout(() => {
|
|
3771
|
+
clearAutoplay();
|
|
3772
|
+
step(autoplayMs > 0 ? 1 : -1);
|
|
3773
|
+
update();
|
|
3774
|
+
}, Math.abs(autoplayMs));
|
|
3775
|
+
if (request.onAutoplayProgress) {
|
|
3776
|
+
const startedAt = Date.now();
|
|
3777
|
+
const tickTimer = () => {
|
|
3778
|
+
request.onAutoplayProgress(Math.max(0, Math.min(1, (Date.now() - startedAt) / Math.abs(autoplayMs))));
|
|
3779
|
+
frame = requestFrame(tickTimer);
|
|
3780
|
+
};
|
|
3781
|
+
tickTimer();
|
|
3299
3782
|
}
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
control: createCssControl(() => ownedAnimationsOf(el, ownedNames), ledger),
|
|
3310
|
-
activate() {
|
|
3311
|
-
finished = new Promise((resolve) => {
|
|
3312
|
-
settle = resolve;
|
|
3313
|
-
});
|
|
3314
|
-
if (scrubbed) {
|
|
3315
|
-
settle?.();
|
|
3316
|
-
return;
|
|
3317
|
-
}
|
|
3318
|
-
const animations = startCssAnimations(el, ledger, ownedNames, activatedBefore);
|
|
3319
|
-
activatedBefore = true;
|
|
3320
|
-
watch(animations);
|
|
3321
|
-
},
|
|
3322
|
-
play() {
|
|
3323
|
-
drive(1);
|
|
3324
|
-
},
|
|
3325
|
-
reverse() {
|
|
3326
|
-
drive(-1);
|
|
3327
|
-
},
|
|
3328
|
-
cancel() {
|
|
3329
|
-
for (const animation of ownedAnimationsOf(el, ownedNames)) animation.cancel();
|
|
3330
|
-
settle?.();
|
|
3331
|
-
},
|
|
3332
|
-
finish() {
|
|
3333
|
-
for (const animation of ownedAnimationsOf(el, ownedNames)) animation.finish();
|
|
3334
|
-
settle?.();
|
|
3335
|
-
},
|
|
3336
|
-
get finished() {
|
|
3337
|
-
return finished;
|
|
3338
|
-
},
|
|
3339
|
-
destroy() {
|
|
3340
|
-
settle?.();
|
|
3783
|
+
};
|
|
3784
|
+
const clearAutoplay = () => {
|
|
3785
|
+
if (timer === null) return;
|
|
3786
|
+
win.clearTimeout(timer);
|
|
3787
|
+
timer = null;
|
|
3788
|
+
if (request.onAutoplayProgress) {
|
|
3789
|
+
cancelFrame(frame);
|
|
3790
|
+
frame = 0;
|
|
3791
|
+
request.onAutoplayProgress(0);
|
|
3341
3792
|
}
|
|
3342
3793
|
};
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
function deferredInstance(setup) {
|
|
3352
|
-
let running;
|
|
3353
|
-
let settle;
|
|
3354
|
-
let finished = Promise.resolve();
|
|
3355
|
-
const teardown = () => {
|
|
3356
|
-
cleanupOf(running)?.();
|
|
3357
|
-
running = void 0;
|
|
3358
|
-
settle?.();
|
|
3794
|
+
function update() {
|
|
3795
|
+
const running = active();
|
|
3796
|
+
if (spinMs !== 0) (running ? startSpin : stopSpin)();
|
|
3797
|
+
if (autoplayMs !== 0) (running ? armAutoplay : clearAutoplay)();
|
|
3798
|
+
}
|
|
3799
|
+
const onEnter = () => {
|
|
3800
|
+
hovered = true;
|
|
3801
|
+
update();
|
|
3359
3802
|
};
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3803
|
+
const onLeave = () => {
|
|
3804
|
+
hovered = false;
|
|
3805
|
+
update();
|
|
3806
|
+
};
|
|
3807
|
+
const onFocusIn = (event) => {
|
|
3808
|
+
focused = (!viewerOpen || focusBeforeViewer) && isKeyboardFocus(event.target);
|
|
3809
|
+
update();
|
|
3810
|
+
};
|
|
3811
|
+
const onFocusOut = (event) => {
|
|
3812
|
+
if (!viewerOpen) focusBeforeViewer = focused;
|
|
3813
|
+
const next = event.relatedTarget;
|
|
3814
|
+
focused = next !== null && el.contains(next) && isKeyboardFocus(next);
|
|
3815
|
+
update();
|
|
3816
|
+
};
|
|
3817
|
+
const onVisibility = () => update();
|
|
3818
|
+
const onViewer = (event) => {
|
|
3819
|
+
const open = event.detail?.open === true;
|
|
3820
|
+
viewerOpen = open;
|
|
3821
|
+
viewing = open && el.contains(event.target);
|
|
3822
|
+
update();
|
|
3823
|
+
};
|
|
3824
|
+
if (pauseOnHover) {
|
|
3825
|
+
el.addEventListener("pointerenter", onEnter);
|
|
3826
|
+
el.addEventListener("pointerleave", onLeave);
|
|
3827
|
+
}
|
|
3828
|
+
el.addEventListener("focusin", onFocusIn);
|
|
3829
|
+
el.addEventListener("focusout", onFocusOut);
|
|
3830
|
+
ctx.doc.addEventListener("visibilitychange", onVisibility);
|
|
3831
|
+
ctx.doc.addEventListener(VIEWER_EVENT, onViewer);
|
|
3832
|
+
const unwatchScope = watchPauseScope(el, ctx.doc, (paused) => {
|
|
3833
|
+
scopePaused = paused;
|
|
3834
|
+
update();
|
|
3382
3835
|
});
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3836
|
+
const Observer = win.IntersectionObserver;
|
|
3837
|
+
const observer = Observer ? new Observer((entries) => {
|
|
3838
|
+
for (const entry of entries) onscreen = entry.isIntersecting;
|
|
3839
|
+
update();
|
|
3840
|
+
}) : null;
|
|
3841
|
+
observer?.observe(el);
|
|
3842
|
+
onPausedChange(userPaused);
|
|
3843
|
+
update();
|
|
3390
3844
|
return {
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
});
|
|
3400
|
-
|
|
3401
|
-
cancel() {
|
|
3402
|
-
hooks.cancel?.();
|
|
3403
|
-
active = false;
|
|
3404
|
-
},
|
|
3405
|
-
finish() {
|
|
3406
|
-
hooks.finish?.();
|
|
3845
|
+
enabled,
|
|
3846
|
+
interrupt() {
|
|
3847
|
+
held = true;
|
|
3848
|
+
if (holdTimer !== null) win.clearTimeout(holdTimer);
|
|
3849
|
+
holdTimer = win.setTimeout(() => {
|
|
3850
|
+
holdTimer = null;
|
|
3851
|
+
held = false;
|
|
3852
|
+
update();
|
|
3853
|
+
}, Math.max(0, settleMs));
|
|
3854
|
+
update();
|
|
3407
3855
|
},
|
|
3408
|
-
|
|
3409
|
-
|
|
3856
|
+
hold(holding) {
|
|
3857
|
+
gesture = holding;
|
|
3858
|
+
update();
|
|
3410
3859
|
},
|
|
3411
|
-
|
|
3412
|
-
|
|
3860
|
+
toggle() {
|
|
3861
|
+
userPaused = !userPaused;
|
|
3862
|
+
onPausedChange(userPaused);
|
|
3863
|
+
update();
|
|
3413
3864
|
},
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3865
|
+
release() {
|
|
3866
|
+
if (frame !== 0) cancelFrame(frame);
|
|
3867
|
+
frame = 0;
|
|
3868
|
+
if (timer !== null) win.clearTimeout(timer);
|
|
3869
|
+
if (holdTimer !== null) win.clearTimeout(holdTimer);
|
|
3870
|
+
timer = null;
|
|
3871
|
+
holdTimer = null;
|
|
3872
|
+
observer?.disconnect();
|
|
3873
|
+
el.removeEventListener("pointerenter", onEnter);
|
|
3874
|
+
el.removeEventListener("pointerleave", onLeave);
|
|
3875
|
+
el.removeEventListener("focusin", onFocusIn);
|
|
3876
|
+
el.removeEventListener("focusout", onFocusOut);
|
|
3877
|
+
ctx.doc.removeEventListener("visibilitychange", onVisibility);
|
|
3878
|
+
ctx.doc.removeEventListener(VIEWER_EVENT, onViewer);
|
|
3879
|
+
unwatchScope();
|
|
3880
|
+
publishSpinning(false);
|
|
3417
3881
|
}
|
|
3418
3882
|
};
|
|
3419
3883
|
}
|
|
@@ -3457,8 +3921,10 @@ export {
|
|
|
3457
3921
|
inertInstance,
|
|
3458
3922
|
SEGMENT_HOIST_KEYS,
|
|
3459
3923
|
EASING_KEYWORDS,
|
|
3924
|
+
splitTopLevel,
|
|
3460
3925
|
parseActivationAttribute,
|
|
3461
3926
|
parse,
|
|
3927
|
+
isGroupOnly,
|
|
3462
3928
|
assignOnce,
|
|
3463
3929
|
Registry,
|
|
3464
3930
|
timingProperty,
|
|
@@ -3469,8 +3935,18 @@ export {
|
|
|
3469
3935
|
control,
|
|
3470
3936
|
KUI_EVENT,
|
|
3471
3937
|
emitLifecycle,
|
|
3938
|
+
provideDeckViewer,
|
|
3939
|
+
announceViewer,
|
|
3940
|
+
DECK_LIGHTBOX_PARAM,
|
|
3941
|
+
deckLightbox,
|
|
3942
|
+
PAUSE_SCOPE_ATTR,
|
|
3943
|
+
announcePauseScope,
|
|
3944
|
+
MIN_PERIOD_MS,
|
|
3945
|
+
clampPeriod,
|
|
3946
|
+
createAutoMotion,
|
|
3472
3947
|
validate,
|
|
3473
3948
|
decimalNumber,
|
|
3949
|
+
isSafeCssValue,
|
|
3474
3950
|
isSameOriginPath,
|
|
3475
3951
|
resolveParams,
|
|
3476
3952
|
ABSOLUTE_BASIS,
|
|
@@ -3485,15 +3961,11 @@ export {
|
|
|
3485
3961
|
claimTargetGroupHost,
|
|
3486
3962
|
staggerRanks,
|
|
3487
3963
|
restageAfterRemoval,
|
|
3964
|
+
releaseStaggerGroup,
|
|
3488
3965
|
releaseStagger,
|
|
3489
3966
|
restageAround,
|
|
3490
3967
|
indexTargetGroup,
|
|
3491
3968
|
applyStagger,
|
|
3492
|
-
createScrollScheduler,
|
|
3493
|
-
windowScrollRoot,
|
|
3494
|
-
createRootResolver,
|
|
3495
|
-
clamp013 as clamp01,
|
|
3496
|
-
createMeasureCache,
|
|
3497
3969
|
TIME_SCALE_ATTR,
|
|
3498
3970
|
timeScaleOf,
|
|
3499
3971
|
createCssInstance,
|
|
@@ -3501,6 +3973,12 @@ export {
|
|
|
3501
3973
|
deferredInstance,
|
|
3502
3974
|
deferPrepare,
|
|
3503
3975
|
createJsInstance,
|
|
3976
|
+
repeatedInstance,
|
|
3977
|
+
createScrollScheduler,
|
|
3978
|
+
windowScrollRoot,
|
|
3979
|
+
createRootResolver,
|
|
3980
|
+
clamp013 as clamp01,
|
|
3981
|
+
createMeasureCache,
|
|
3504
3982
|
ALL_TIMING_TOKENS,
|
|
3505
3983
|
declareTimingContract,
|
|
3506
3984
|
inheritTimingContract,
|