@wardic/dom 1.2.0 → 1.3.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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/default-transition.d.ts +1 -1
- package/dist/internal/default-transition.d.ts.map +1 -1
- package/dist/internal/default-transition.js +4 -20
- package/dist/internal/default-transition.js.map +1 -1
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +3 -0
- package/dist/internal/renderer.js.map +1 -1
- package/dist/unstable/BatchMembers.d.ts +2 -2
- package/dist/unstable/BatchMembers.d.ts.map +1 -1
- package/dist/unstable/BatchMembers.js +32 -271
- package/dist/unstable/BatchMembers.js.map +1 -1
- package/dist/unstable/Imperative.d.ts +13 -136
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +59 -721
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/PresenceController.js +4 -4
- package/dist/unstable/PresenceController.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/internal/default-transition.ts +5 -27
- package/src/internal/renderer.ts +3 -0
- package/src/unstable/BatchMembers.ts +35 -270
- package/src/unstable/Imperative.ts +69 -917
- package/src/unstable/PresenceController.ts +4 -4
|
@@ -46,7 +46,9 @@ import * as Result from "effect/Result";
|
|
|
46
46
|
import * as UndefinedOr from "effect/UndefinedOr";
|
|
47
47
|
import * as AppearAnimations from "./AppearAnimations.js";
|
|
48
48
|
import * as PresenceRecord from "@wardic/core/unstable/PresenceRecord";
|
|
49
|
-
|
|
49
|
+
// #882 (ADR-0073, *Amendment (#882)*, PR 3): the calls' environment-agnostic part, core's, shared with `@wardic/object`.
|
|
50
|
+
import * as BatchCalls from "@wardic/core/unstable/BatchCalls";
|
|
51
|
+
import { delayedBy, INSTANT, isFirstStop, isPair, memberTransitionsOf, staggerOf, unstaggered } from "@wardic/core/unstable/BatchCalls";
|
|
50
52
|
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
|
|
51
53
|
/** Whether a Batch's config is the keyed form's. */
|
|
52
54
|
export const isKeyed = (config) => Predicate.hasProperty(config, "each");
|
|
@@ -75,8 +77,6 @@ export const batchSubjectOf = (subject) => {
|
|
|
75
77
|
return undefined;
|
|
76
78
|
return SUBJECTS.get(subject);
|
|
77
79
|
};
|
|
78
|
-
/** Whether `value` is a Batch's key's first stop through an element: a number, or `null` for where it is. */
|
|
79
|
-
const isFirstStop = /*#__PURE__*/ Predicate.or(Predicate.isNumber, Predicate.isNull);
|
|
80
80
|
/** Whether `value` is a Batch's key's two stops through an element: a first stop, and a number. */
|
|
81
81
|
const isElementStops = (value) => {
|
|
82
82
|
if (!isPair(value))
|
|
@@ -139,30 +139,16 @@ const keysKept = (animation, keep) => {
|
|
|
139
139
|
* A compiled sequence's parts (Q40): each Batch's members as one part, in the order they first appear,
|
|
140
140
|
* their Batch keys its; each member's other keys as its element's; every other subject as it is.
|
|
141
141
|
*/
|
|
142
|
-
export const sequencePartsOf = (compiled) =>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (Predicate.isUndefined(part)) {
|
|
153
|
-
part = { members: [], animations: [] };
|
|
154
|
-
byBinding.set(binding, part);
|
|
155
|
-
}
|
|
156
|
-
part.members.push(member);
|
|
157
|
-
part.animations.push(animation);
|
|
158
|
-
// Its keys the Batch doesn't have, its element's: a member element's Segment gave them.
|
|
159
|
-
const rest = keysKept(animation, (key) => binding.routeOf(key) !== "batch");
|
|
160
|
-
const element = binding.elementOf(member);
|
|
161
|
-
if (Bool.and(Predicate.isNotUndefined(rest), Predicate.isNotUndefined(element)))
|
|
162
|
-
others.push([element, rest]);
|
|
163
|
-
});
|
|
164
|
-
return { batches: Arr.map(Arr.fromIterable(byBinding), ([binding, part]) => ({ binding, ...part })), others };
|
|
165
|
-
};
|
|
142
|
+
export const sequencePartsOf = (compiled) =>
|
|
143
|
+
// Core's grouping (#882), a member's keys the Batch doesn't have its element's: a member element's Segment gave them.
|
|
144
|
+
BatchCalls.sequencePartsOf(compiled, (member, animation) => {
|
|
145
|
+
const { binding } = member;
|
|
146
|
+
const rest = keysKept(animation, (key) => binding.routeOf(key) !== "batch");
|
|
147
|
+
const element = binding.elementOf(member.member);
|
|
148
|
+
if (Bool.and(Predicate.isNotUndefined(rest), Predicate.isNotUndefined(element)))
|
|
149
|
+
return [element, rest];
|
|
150
|
+
return undefined;
|
|
151
|
+
});
|
|
166
152
|
/**
|
|
167
153
|
* An element call's parts (#665, Q14, Q35): each Batch's member elements as one part, in list order,
|
|
168
154
|
* with the Batch's keys; each element, a member's with the keys left, as one of its own.
|
|
@@ -173,7 +159,7 @@ export const callPartsOf = (elements, target) => {
|
|
|
173
159
|
Arr.forEach(elements, (element, index) => {
|
|
174
160
|
const entry = MEMBER_ELEMENTS.get(element);
|
|
175
161
|
if (Predicate.isUndefined(entry)) {
|
|
176
|
-
parts.push({ element, index, target });
|
|
162
|
+
parts.push({ subject: element, index, target });
|
|
177
163
|
return;
|
|
178
164
|
}
|
|
179
165
|
let part = byBinding.get(entry.binding);
|
|
@@ -185,10 +171,10 @@ export const callPartsOf = (elements, target) => {
|
|
|
185
171
|
// Its other keys by its place in the list, as a plain element's (Motion's `delay(i, n)`).
|
|
186
172
|
const rest = part.split.rest;
|
|
187
173
|
if (Predicate.isNotUndefined(rest))
|
|
188
|
-
parts.push({ element, index, target: rest });
|
|
174
|
+
parts.push({ subject: element, index, target: rest });
|
|
189
175
|
});
|
|
190
176
|
const members = Arr.filter(Arr.map(Arr.fromIterable(byBinding), ([binding, part]) => ({ binding, members: part.members, target: part.split.batch })), (part) => !Rec.isEmptyRecord(part.target));
|
|
191
|
-
return { members,
|
|
177
|
+
return { members, subjects: parts };
|
|
192
178
|
};
|
|
193
179
|
/** What an error about a Batch says. */
|
|
194
180
|
export const fail = (message) => {
|
|
@@ -231,46 +217,12 @@ const keysFrom = (count, targetsAt, startAt) => {
|
|
|
231
217
|
};
|
|
232
218
|
/** The keys a Batch's members give by index. */
|
|
233
219
|
const keysOf = (config) => keysFrom(config.count, (i) => config.animate(i), (i) => initialOf(config, i));
|
|
234
|
-
/** One change that lands every key at once: `skipAnimations`'. */
|
|
235
|
-
const INSTANT = { type: "tween", duration: 0 };
|
|
236
220
|
/** A key's index, -1 for a key the Batch hasn't. Built once. */
|
|
237
221
|
const keyIndexOr = /*#__PURE__*/ UndefinedOr.match({ onUndefined: () => -1, onDefined: (k) => k });
|
|
238
222
|
/** A Batch Reorder group's item in hand's change (#712): its `x` and `y` where it's held, at once. */
|
|
239
223
|
const IN_HAND = { transition: { x: INSTANT, y: INSTANT } };
|
|
240
|
-
/** A
|
|
241
|
-
|
|
242
|
-
const LANDINGS = new Map();
|
|
243
|
-
const landingAfter = (delay) => {
|
|
244
|
-
const known = LANDINGS.get(delay);
|
|
245
|
-
if (Predicate.isNotUndefined(known))
|
|
246
|
-
return known;
|
|
247
|
-
const made = { duration: 0, delay };
|
|
248
|
-
LANDINGS.set(delay, made);
|
|
249
|
-
return made;
|
|
250
|
-
};
|
|
251
|
-
/** A Batch key's stop in a sequence, as core's Batch takes it: a number, `NaN` for `null`. */
|
|
252
|
-
const stopNumber = (stop) => {
|
|
253
|
-
if (Predicate.isNumber(stop))
|
|
254
|
-
return stop;
|
|
255
|
-
return Number.NaN;
|
|
256
|
-
};
|
|
257
|
-
/** A key's last stop that's a number, `NaN` (where it is) for none: what its `null`s after it hold. */
|
|
258
|
-
const lastNumber = (stops) => Option.getOrElse(Arr.findLast(stops, (stop) => !Number.isNaN(stop)), () => Number.NaN);
|
|
259
|
-
/** Whether `value` is a Batch key's value in a sequence: a number, `null`, or stops of them. */
|
|
260
|
-
const isSegmentStops = (value) => {
|
|
261
|
-
if (isFirstStop(value))
|
|
262
|
-
return true;
|
|
263
|
-
if (!Arr.isArray(value))
|
|
264
|
-
return false;
|
|
265
|
-
return Arr.every(value, isFirstStop);
|
|
266
|
-
};
|
|
267
|
-
/** A Batch key's value in a sequence (Q38): a number, `null` or stops of them; else an error naming the key, and the member a function gave it. */
|
|
268
|
-
const segmentValueOf = (key, value, memberName) => {
|
|
269
|
-
if (isSegmentStops(value))
|
|
270
|
-
return value;
|
|
271
|
-
const whose = UndefinedOr.match(memberName, { onUndefined: () => "", onDefined: (name) => `${name}'s ` });
|
|
272
|
-
return fail(`a sequence gives ${whose}"${key}" as ${JSON.stringify(value)}: a Batch's key takes a number, \`null\`, or stops of them`);
|
|
273
|
-
};
|
|
224
|
+
/** A Batch key's value in a sequence (Q38): core's, its error createBatch's. */
|
|
225
|
+
const segmentValueOf = (key, value, memberName) => BatchCalls.segmentValueOf(key, value, memberName, fail);
|
|
274
226
|
/**
|
|
275
227
|
* An `exit`, `whileHover` or `whileTap` given as an object, values with an optional `transition` (Q48,
|
|
276
228
|
* Q58), else `undefined`: a function's values are read as each is needed.
|
|
@@ -412,114 +364,9 @@ export const markLayoutElement = (element) => {
|
|
|
412
364
|
const layoutOnMember = (element) => `a member's element (${elementName(element)}) has \`layout\` or \`layoutId\`: the Batch draws its transform, under which the projection measures it. Give its Wardic element no layout, or leave it out of the Batch`;
|
|
413
365
|
/** No values: an exit with none, which moves nothing and lets its element go at once. */
|
|
414
366
|
const NO_VALUES = {};
|
|
415
|
-
/**
|
|
416
|
-
const isPair = (value) => {
|
|
417
|
-
if (!Arr.isArray(value))
|
|
418
|
-
return false;
|
|
419
|
-
return value.length === 2;
|
|
420
|
-
};
|
|
421
|
-
/** Reduced motion's Snap after `delay`: a 0 s tween, kept by its delay so its keys share one. */
|
|
422
|
-
// Module state (#460, Q7): a cache built once, keyed by what it caches.
|
|
423
|
-
const SNAPS = new Map();
|
|
424
|
-
const snapAfter = (delay) => {
|
|
425
|
-
const known = SNAPS.get(delay);
|
|
426
|
-
if (Predicate.isNotUndefined(known))
|
|
427
|
-
return known;
|
|
428
|
-
const made = { type: "tween", duration: 0, delay };
|
|
429
|
-
SNAPS.set(delay, made);
|
|
430
|
-
return made;
|
|
431
|
-
};
|
|
432
|
-
/**
|
|
433
|
-
* A Default transition held by a key's own `delay`, as a Wardic element's is when its transition gives
|
|
434
|
-
* only a delay (ADR-0051): one object for each transition and delay, so the members on it share it.
|
|
435
|
-
*/
|
|
436
|
-
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
437
|
-
const DELAYED = new WeakMap();
|
|
438
|
-
const delayedBy = (transition, delay) => {
|
|
439
|
-
if (delay === 0)
|
|
440
|
-
return transition;
|
|
441
|
-
let byDelay = DELAYED.get(transition);
|
|
442
|
-
if (Predicate.isUndefined(byDelay)) {
|
|
443
|
-
byDelay = new Map();
|
|
444
|
-
DELAYED.set(transition, byDelay);
|
|
445
|
-
}
|
|
446
|
-
const known = byDelay.get(delay);
|
|
447
|
-
if (Predicate.isNotUndefined(known))
|
|
448
|
-
return known;
|
|
449
|
-
const made = { ...transition, delay };
|
|
450
|
-
byDelay.set(delay, made);
|
|
451
|
-
return made;
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* A transition without a `stagger()` delay, which a change gives each member by its place: one object
|
|
455
|
-
* each. A `delay` in seconds stays, held by the keys the transition's own fields reach, as a Wardic
|
|
456
|
-
* element's top-level delay is.
|
|
457
|
-
*/
|
|
458
|
-
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
459
|
-
const UNSTAGGERED = new WeakMap();
|
|
460
|
-
const unstaggered = (given) => {
|
|
461
|
-
if (!Predicate.isFunction(given.delay))
|
|
462
|
-
return given;
|
|
463
|
-
const known = UNSTAGGERED.get(given);
|
|
464
|
-
if (Predicate.isNotUndefined(known))
|
|
465
|
-
return known;
|
|
466
|
-
const made = { ...given, delay: undefined };
|
|
467
|
-
UNSTAGGERED.set(given, made);
|
|
468
|
-
return made;
|
|
469
|
-
};
|
|
470
|
-
/** A change's `stagger()` delay, for the members it moves; `undefined` for none. */
|
|
471
|
-
const staggerOf = (given) => {
|
|
472
|
-
if (Predicate.isUndefined(given))
|
|
473
|
-
return undefined;
|
|
474
|
-
const delay = given.delay;
|
|
475
|
-
if (Predicate.isFunction(delay))
|
|
476
|
-
return delay;
|
|
477
|
-
return undefined;
|
|
478
|
-
};
|
|
479
|
-
/** A key's transition as a Batch runs it: its run, which can't be an inertia or repeat. */
|
|
480
|
-
const batchRunOf = (run, key) => {
|
|
481
|
-
if (run.type === "inertia")
|
|
482
|
-
fail(`"${key}" has an inertia transition, which a Batch can't run: give it a spring or a tween`);
|
|
483
|
-
if (Predicate.hasProperty(run, "repeat"))
|
|
484
|
-
fail(`"${key}"'s transition repeats, which a Batch can't run`);
|
|
485
|
-
return run;
|
|
486
|
-
};
|
|
487
|
-
/**
|
|
488
|
-
* Each key's plan for a change, by its index, as a Wardic element's keys run (#301): its entry, else
|
|
489
|
-
* `default`, else the transition's own fields; reduced motion's Snap for a positional key that doesn't
|
|
490
|
-
* opt out; its Default transition, held by its own `delay`, for a key whose transition isn't defined.
|
|
491
|
-
*/
|
|
367
|
+
/** Each key's plan for a change (#301): core's, its errors createBatch's. */
|
|
492
368
|
// Once a change, per key.
|
|
493
|
-
const plannedOf = (positional, keys, given, reduced) =>
|
|
494
|
-
const transition = RetargetLegs.transitionForKey(given, key);
|
|
495
|
-
let delay = 0;
|
|
496
|
-
let respects = true;
|
|
497
|
-
if (Predicate.isNotUndefined(transition)) {
|
|
498
|
-
if (Predicate.isNumber(transition.delay))
|
|
499
|
-
delay = transition.delay;
|
|
500
|
-
respects = transition.respectReducedMotion !== false;
|
|
501
|
-
}
|
|
502
|
-
if (reduced && respects && positional.isPositional(key))
|
|
503
|
-
return { own: snapAfter(delay), delay };
|
|
504
|
-
const run = RetargetLegs.runOf(transition);
|
|
505
|
-
if (Predicate.isUndefined(run))
|
|
506
|
-
return { own: undefined, delay };
|
|
507
|
-
return { own: batchRunOf(run, key), delay };
|
|
508
|
-
});
|
|
509
|
-
/**
|
|
510
|
-
* A member's transitions on `keys` for a change planned as `planned`: each key's own, else its Default
|
|
511
|
-
* transition (`defaultFor`) toward its target there, `targetAt(k)`; every key at once when it's skipped.
|
|
512
|
-
* A server's Appear plan's (#706) and a client's check of it.
|
|
513
|
-
*/
|
|
514
|
-
// Per member per key, at a server's render and at a hydrating client's first change (#706): statements.
|
|
515
|
-
const memberTransitionsOf = (keys, planned, defaultFor, targetAt, skipped) => Arr.map(keys, (key, k) => {
|
|
516
|
-
if (skipped)
|
|
517
|
-
return INSTANT;
|
|
518
|
-
const plan = planned[k];
|
|
519
|
-
if (Predicate.isNotUndefined(plan.own))
|
|
520
|
-
return plan.own;
|
|
521
|
-
return delayedBy(defaultFor(key, targetAt(k)), plan.delay);
|
|
522
|
-
});
|
|
369
|
+
const plannedOf = (positional, keys, given, reduced) => BatchCalls.plannedOf(positional, keys, given, reduced, fail);
|
|
523
370
|
/** The Handoff's module, once it has loaded (#706, Q11): every Batch after the first takes its members over at once. */
|
|
524
371
|
// Module state (#460, Q7): one module, loaded once for the page.
|
|
525
372
|
let handoffModule = undefined;
|
|
@@ -992,6 +839,11 @@ export const bindBatch = (env, config, hooks) => {
|
|
|
992
839
|
// Its gestures as given (#665's PR 5): `whileHover` and `whileTap`, an object or a function.
|
|
993
840
|
/** A key's Default transition toward `target`. */
|
|
994
841
|
const defaultFor = (k, target) => env.defaultTransition.transitionFor(keys[k], target);
|
|
842
|
+
/** What core's calls are told of the Batch (#882): its keys now, its Environment's, and createBatch's errors. */
|
|
843
|
+
const planningNow = () => ({ keys, positionalKeys: env.positionalKeys, defaultFor, fail });
|
|
844
|
+
/** Its members as core's calls name them (#882): by slot, a call's, and by number, a Segment's; their place in the list, the count, an error's name. */
|
|
845
|
+
const bySlot = { indexOf: (slot) => indexOf[memberOf[slot]], count: () => form.size(), nameOf: (slot) => form.nameOf(memberOf[slot]) };
|
|
846
|
+
const byMember = { indexOf: (i) => indexOf[i], count: () => form.size(), nameOf: (i) => form.nameOf(i) };
|
|
995
847
|
/** The Batch's keys, fixed from now on, and room for every member's targets on them. */
|
|
996
848
|
const keysAre = (given) => {
|
|
997
849
|
keys = given;
|
|
@@ -2218,15 +2070,6 @@ export const bindBatch = (env, config, hooks) => {
|
|
|
2218
2070
|
}
|
|
2219
2071
|
enter(i, el);
|
|
2220
2072
|
};
|
|
2221
|
-
/** One stop's value for member `i`: a number, or a function's of its index and the count. */
|
|
2222
|
-
const stopAt = (key, stop, i) => {
|
|
2223
|
-
let value = stop;
|
|
2224
|
-
if (Predicate.isFunction(stop))
|
|
2225
|
-
value = stop(indexOf[i], form.size());
|
|
2226
|
-
if (Predicate.isNumber(value))
|
|
2227
|
-
return value;
|
|
2228
|
-
return fail(`an animate call's "${key}" gives ${form.nameOf(i)} ${JSON.stringify(value)}: a Batch takes numbers`);
|
|
2229
|
-
};
|
|
2230
2073
|
/** The slots an `animate` call moves: every member's there is, or the members it names, in order, whose elements have arrived. */
|
|
2231
2074
|
const callSlotsOf = (named) => UndefinedOr.match(named, {
|
|
2232
2075
|
// A copy: the call keeps it, and members arrive after.
|
|
@@ -2254,70 +2097,18 @@ export const bindBatch = (env, config, hooks) => {
|
|
|
2254
2097
|
if (Predicate.isUndefined(batch))
|
|
2255
2098
|
return landedTrack(call.settled);
|
|
2256
2099
|
const slots = callSlotsOf(call.members);
|
|
2257
|
-
// Each member's stops by key, its target and its first, `NaN` for none: worked out once, at the call.
|
|
2258
|
-
const
|
|
2259
|
-
const froms = new Float64Array(capacity * stride).fill(Number.NaN);
|
|
2260
|
-
let firsts = false;
|
|
2261
|
-
const given = call.target;
|
|
2262
|
-
Arr.forEach(Rec.keys(given), (key) => {
|
|
2263
|
-
const k = keyIndex.get(key);
|
|
2264
|
-
if (Predicate.isUndefined(k))
|
|
2265
|
-
return fail(`an animate call gives "${key}", which isn't one of the Batch's keys (${keys.join(", ")})`);
|
|
2266
|
-
const value = given[key];
|
|
2267
|
-
// Per member per key at a call (#665): statements.
|
|
2268
|
-
Arr.forEach(slots, (slot) => {
|
|
2269
|
-
const i = memberOf[slot];
|
|
2270
|
-
const at = i * stride + k;
|
|
2271
|
-
let stops = value;
|
|
2272
|
-
if (Predicate.isFunction(value))
|
|
2273
|
-
stops = value(indexOf[i], form.size());
|
|
2274
|
-
if (isPair(stops)) {
|
|
2275
|
-
froms[at] = stopAt(key, stops[0], i);
|
|
2276
|
-
tos[at] = stopAt(key, stops[1], i);
|
|
2277
|
-
firsts = true;
|
|
2278
|
-
return;
|
|
2279
|
-
}
|
|
2280
|
-
if (Predicate.isNumber(stops)) {
|
|
2281
|
-
tos[at] = stops;
|
|
2282
|
-
return;
|
|
2283
|
-
}
|
|
2284
|
-
return fail(`an animate call's "${key}" is ${JSON.stringify(stops)}: a Batch takes a number or two, its first and its target, or a function of a member's index that gives them`);
|
|
2285
|
-
});
|
|
2286
|
-
});
|
|
2287
|
-
const fromOf = (slot, k) => froms[memberOf[slot] * stride + k];
|
|
2288
|
-
const toOf = (slot, k) => tos[memberOf[slot] * stride + k];
|
|
2100
|
+
// Each member's stops by key, its target and its first, `NaN` for none: worked out once, at the call (core's).
|
|
2101
|
+
const { toOf, fromOf } = BatchCalls.callTargets(planningNow(), keyIndex, bySlot, slots, call.target);
|
|
2289
2102
|
// The groups Wardic elements hold of its members that it moves come back first, from where they've left them (Q54).
|
|
2290
2103
|
retakeFor(slots, givesGroup((slot, k) => !Number.isNaN(toOf(slot, k))));
|
|
2291
|
-
return changeOn(slots, toOf,
|
|
2104
|
+
return changeOn(slots, toOf, fromOf, call);
|
|
2292
2105
|
};
|
|
2293
2106
|
/**
|
|
2294
2107
|
* A driven change of `slots` toward `targetOf`, from `fromOf`'s first stops when it gives them, on its
|
|
2295
2108
|
* call's transitions (which the Batch copies for it, so the Playhead driving them reaches its keys
|
|
2296
2109
|
* alone), its `stagger()` counting the members it moves: an `animate` call's, or a keyed Batch's exits.
|
|
2297
2110
|
*/
|
|
2298
|
-
const changeOn = (slots, targetOf, fromOf, call) =>
|
|
2299
|
-
const transition = Bool.match(call.skipAnimations, {
|
|
2300
|
-
onTrue: () => () => INSTANT,
|
|
2301
|
-
onFalse: () => {
|
|
2302
|
-
const planned = plannedOf(env.positionalKeys, keys, UndefinedOr.map(call.transition, unstaggered), call.reducedMotion);
|
|
2303
|
-
return (slot, k) => {
|
|
2304
|
-
const plan = planned[k];
|
|
2305
|
-
if (Predicate.isNotUndefined(plan.own))
|
|
2306
|
-
return plan.own;
|
|
2307
|
-
return delayedBy(defaultFor(k, targetOf(slot, k)), plan.delay);
|
|
2308
|
-
};
|
|
2309
|
-
},
|
|
2310
|
-
});
|
|
2311
|
-
const options = { head: call.head, transition, onLanded: call.settled };
|
|
2312
|
-
if (Predicate.isNotUndefined(fromOf))
|
|
2313
|
-
options.from = fromOf;
|
|
2314
|
-
if (Predicate.isNotUndefined(call.onMemberLanded))
|
|
2315
|
-
options.onMemberLanded = call.onMemberLanded;
|
|
2316
|
-
const delay = Bool.match(call.skipAnimations, { onTrue: () => undefined, onFalse: () => staggerOf(call.transition) });
|
|
2317
|
-
if (Predicate.isNotUndefined(delay))
|
|
2318
|
-
options.delay = delay;
|
|
2319
|
-
return controlsOf(Batch.animate(made(), slots, targetOf, options));
|
|
2320
|
-
};
|
|
2111
|
+
const changeOn = (slots, targetOf, fromOf, call) => controlsOf(Batch.animate(made(), slots, targetOf, BatchCalls.animateOptions(planningNow(), call, targetOf, fromOf)));
|
|
2321
2112
|
/** Whether member `i`'s element has arrived. */
|
|
2322
2113
|
const hasArrived = (i) => slotOf[i] !== NO_SLOT;
|
|
2323
2114
|
/** The members a sequence's Segment moves (Q39): every member whose element has arrived, in the list's order, or those `named` names once theirs have. */
|
|
@@ -2327,19 +2118,7 @@ export const bindBatch = (env, config, hooks) => {
|
|
|
2327
2118
|
if (Predicate.isUndefined(batch))
|
|
2328
2119
|
return { subjects: [], values: {} };
|
|
2329
2120
|
const moving = membersOf(named);
|
|
2330
|
-
const values =
|
|
2331
|
-
Arr.forEach(Rec.keys(target), (key) => {
|
|
2332
|
-
const value = target[key];
|
|
2333
|
-
if (Predicate.isUndefined(value))
|
|
2334
|
-
return;
|
|
2335
|
-
if (!keyIndex.has(key))
|
|
2336
|
-
return fail(`a sequence's Segment of a Batch gives "${key}", which isn't one of its keys (${keys.join(", ")})`);
|
|
2337
|
-
if (Predicate.isFunction(value)) {
|
|
2338
|
-
values[key] = (index) => segmentValueOf(key, value(indexOf[moving[index]], form.size()), form.nameOf(moving[index]));
|
|
2339
|
-
return;
|
|
2340
|
-
}
|
|
2341
|
-
values[key] = segmentValueOf(key, value, undefined);
|
|
2342
|
-
});
|
|
2121
|
+
const values = BatchCalls.segmentValues(planningNow(), (key) => keyIndex.has(key), byMember, moving, target);
|
|
2343
2122
|
return { subjects: Arr.map(moving, (i) => UndefinedOr.getOrThrow(entries[i])), values };
|
|
2344
2123
|
};
|
|
2345
2124
|
/** A sequence's Segment of members' elements (Q40): a Batch key's value a number, `null` or stops; no transform the Batch draws without it. */
|
|
@@ -2369,26 +2148,8 @@ export const bindBatch = (env, config, hooks) => {
|
|
|
2369
2148
|
});
|
|
2370
2149
|
// The groups Wardic elements hold of its members that it moves come back first (Q54).
|
|
2371
2150
|
retakeFor(slots, givesGroup((slot, k) => Predicate.isNotUndefined(UndefinedOr.getOrThrow(animations[slot]).keyframes[keys[k]])));
|
|
2372
|
-
//
|
|
2373
|
-
const keyframesOf = (
|
|
2374
|
-
const key = keys[k];
|
|
2375
|
-
const animation = UndefinedOr.getOrThrow(animations[slot]);
|
|
2376
|
-
const given = animation.keyframes[key];
|
|
2377
|
-
if (Predicate.isUndefined(given))
|
|
2378
|
-
return undefined;
|
|
2379
|
-
const transition = UndefinedOr.getOrThrow(animation.transition[key]);
|
|
2380
|
-
const stops = Arr.map(given, stopNumber);
|
|
2381
|
-
const snaps = call.reducedMotion && env.positionalKeys.isPositional(key);
|
|
2382
|
-
if (!call.skipAnimations && !snaps)
|
|
2383
|
-
return { stops, transition };
|
|
2384
|
-
// Where its run would end, from where it is: after its delay for reduced motion's Snap, at once when
|
|
2385
|
-
// skipped. Its last stop is its last number: a sequence ends a key with a `null` when its last Segment ends first.
|
|
2386
|
-
const end = ReducedMotion.endOf(stops[0], lastNumber(stops), transition);
|
|
2387
|
-
let delay = 0;
|
|
2388
|
-
if (!call.skipAnimations && Predicate.isNotUndefined(transition.delay))
|
|
2389
|
-
delay = transition.delay;
|
|
2390
|
-
return { stops: [Number.NaN, end], transition: landingAfter(delay) };
|
|
2391
|
-
};
|
|
2151
|
+
// Each member's key's stops, once at its first play (core's).
|
|
2152
|
+
const keyframesOf = BatchCalls.keyframesFor(planningNow(), call, (slot) => UndefinedOr.getOrThrow(animations[slot]));
|
|
2392
2153
|
return controlsOf(Batch.keyframes(made(), slots, keyframesOf, { head: call.head, onLanded: call.settled }));
|
|
2393
2154
|
};
|
|
2394
2155
|
/** A driven change's controls, as an `animate` call's track: played, it wakes the Batch's run. */
|