motion-dom 12.41.0 → 12.42.1
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/cjs/index.js +207 -91
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/view/index.mjs +41 -8
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/es/view/start.mjs +136 -81
- package/dist/es/view/start.mjs.map +1 -1
- package/dist/es/view/utils/assign-names.mjs +30 -2
- package/dist/es/view/utils/assign-names.mjs.map +1 -1
- package/dist/index.d.ts +36 -6
- package/dist/motion-dom.dev.js +207 -91
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -5334,6 +5334,29 @@ function tagClass(element, className, classed) {
|
|
|
5334
5334
|
element.style?.setProperty("view-transition-class", className);
|
|
5335
5335
|
classed.push(element);
|
|
5336
5336
|
}
|
|
5337
|
+
/**
|
|
5338
|
+
* Set the element's `view-transition-group` so its layer reconstructs the DOM
|
|
5339
|
+
* hierarchy in the pseudo-tree (`contain`) - or stays flat (`none`). Tracked in
|
|
5340
|
+
* `grouped` for cleanup. When the element clips (any non-`visible` overflow) its
|
|
5341
|
+
* name is recorded in `clipChildren` so the caller can clip the nested children
|
|
5342
|
+
* (`::view-transition-group-children(name)`), mirroring the live clip through
|
|
5343
|
+
* the whole transition rather than only at the live-DOM handoff.
|
|
5344
|
+
*
|
|
5345
|
+
* Ignored by browsers without nested view-transition groups, where it harmlessly
|
|
5346
|
+
* degrades to the flat default.
|
|
5347
|
+
*/
|
|
5348
|
+
function applyGroup(element, name, group, grouped, clipChildren) {
|
|
5349
|
+
if (!group)
|
|
5350
|
+
return;
|
|
5351
|
+
element.style?.setProperty("view-transition-group", group);
|
|
5352
|
+
grouped.push(element);
|
|
5353
|
+
if (group !== "none" && clipChildren) {
|
|
5354
|
+
const style = getComputedStyle(element);
|
|
5355
|
+
if (style.overflowX !== "visible" || style.overflowY !== "visible") {
|
|
5356
|
+
clipChildren.add(name);
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5337
5360
|
/**
|
|
5338
5361
|
* Resolve a selector/Element to elements and ensure each one carries a
|
|
5339
5362
|
* `view-transition-name` we can target from script.
|
|
@@ -5347,7 +5370,7 @@ function tagClass(element, className, classed) {
|
|
|
5347
5370
|
* across both captures (before and after the update), which is what allows a
|
|
5348
5371
|
* persistent element to animate as a single `group` layer.
|
|
5349
5372
|
*/
|
|
5350
|
-
function assignViewTransitionNames(definition, registry, assigned, forcedNames, className, classed = []) {
|
|
5373
|
+
function assignViewTransitionNames(definition, registry, assigned, forcedNames, className, classed = [], group, grouped = [], clipChildren) {
|
|
5351
5374
|
const elements = resolveElements(definition);
|
|
5352
5375
|
/**
|
|
5353
5376
|
* The new end of a paired morph: give each element the matching name from
|
|
@@ -5368,6 +5391,7 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
5368
5391
|
assigned.push(element);
|
|
5369
5392
|
registry.set(element, name);
|
|
5370
5393
|
tagClass(element, className, classed);
|
|
5394
|
+
applyGroup(element, name, group, grouped, clipChildren);
|
|
5371
5395
|
return name;
|
|
5372
5396
|
});
|
|
5373
5397
|
}
|
|
@@ -5408,6 +5432,7 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
5408
5432
|
}
|
|
5409
5433
|
registry.set(element, name);
|
|
5410
5434
|
tagClass(element, className, classed);
|
|
5435
|
+
applyGroup(element, name, group, grouped, clipChildren);
|
|
5411
5436
|
return name;
|
|
5412
5437
|
});
|
|
5413
5438
|
}
|
|
@@ -5417,13 +5442,16 @@ function assignViewTransitionNames(definition, registry, assigned, forcedNames,
|
|
|
5417
5442
|
* (they're not in `assigned`). Safe to call more than once (e.g. on both a
|
|
5418
5443
|
* finished and an interrupted transition).
|
|
5419
5444
|
*/
|
|
5420
|
-
function releaseViewTransitionNames(assigned, classed = []) {
|
|
5445
|
+
function releaseViewTransitionNames(assigned, classed = [], grouped = []) {
|
|
5421
5446
|
for (const element of assigned) {
|
|
5422
5447
|
element.style?.removeProperty("view-transition-name");
|
|
5423
5448
|
}
|
|
5424
5449
|
for (const element of classed) {
|
|
5425
5450
|
element.style?.removeProperty("view-transition-class");
|
|
5426
5451
|
}
|
|
5452
|
+
for (const element of grouped) {
|
|
5453
|
+
element.style?.removeProperty("view-transition-group");
|
|
5454
|
+
}
|
|
5427
5455
|
}
|
|
5428
5456
|
|
|
5429
5457
|
function chooseLayerType(valueName) {
|
|
@@ -5508,14 +5536,14 @@ const ORIGIN_DEFAULTS = {
|
|
|
5508
5536
|
new: { opacity: 0, scale: 0.85 },
|
|
5509
5537
|
old: { opacity: 1, scale: 1 },
|
|
5510
5538
|
};
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5539
|
+
/**
|
|
5540
|
+
* How much two box aspect ratios must differ before a morph is treated as
|
|
5541
|
+
* aspect-changing (and so worth cropping). Matches the projection engine's
|
|
5542
|
+
* `preserve-aspect` threshold, so small layout jitter doesn't trigger a crop.
|
|
5543
|
+
*/
|
|
5544
|
+
const ASPECT_TOLERANCE = 0.2;
|
|
5517
5545
|
function startViewAnimation(builder) {
|
|
5518
|
-
const { update, targets, resolveDefs,
|
|
5546
|
+
const { update, targets, resolveDefs, cropOverride, pairs, classNames, flatGroups, options: defaultOptions, } = builder;
|
|
5519
5547
|
if (!document.startViewTransition) {
|
|
5520
5548
|
// An async IIFE (not `new Promise(async …)`) so a throwing/rejecting
|
|
5521
5549
|
// update rejects this promise rather than leaving it unsettled.
|
|
@@ -5539,8 +5567,21 @@ function startViewAnimation(builder) {
|
|
|
5539
5567
|
* ever stripping an author's own inline `view-transition-name`.
|
|
5540
5568
|
*/
|
|
5541
5569
|
const classed = [];
|
|
5570
|
+
/**
|
|
5571
|
+
* Elements we set a `view-transition-group` on (for nesting), tracked for
|
|
5572
|
+
* cleanup. `clipChildren` collects the names of nested parents that clip in
|
|
5573
|
+
* the live layout, so their `::view-transition-group-children` is clipped
|
|
5574
|
+
* through the transition - not just once the live DOM takes back over.
|
|
5575
|
+
*/
|
|
5576
|
+
const grouped = [];
|
|
5577
|
+
const clipChildren = new Set();
|
|
5542
5578
|
const layerTargets = new Map();
|
|
5543
5579
|
const croppedNames = new Set();
|
|
5580
|
+
/**
|
|
5581
|
+
* Each layer's explicit `.crop(true | false)` override (by resolved name),
|
|
5582
|
+
* so `finalizeCrop` can let an author's choice win over the morph default.
|
|
5583
|
+
*/
|
|
5584
|
+
const cropForName = new Map();
|
|
5544
5585
|
/**
|
|
5545
5586
|
* Each layer's stagger position (index + total) within its subject, per
|
|
5546
5587
|
* snapshot. Resolving against the snapshot the layer belongs to keeps
|
|
@@ -5562,6 +5603,18 @@ function startViewAnimation(builder) {
|
|
|
5562
5603
|
const resolveLayers = (phase) => {
|
|
5563
5604
|
targets.forEach((target, definition) => {
|
|
5564
5605
|
const className = classNames.get(definition);
|
|
5606
|
+
/**
|
|
5607
|
+
* Nest each resolved layer under its DOM-ancestor layer by default
|
|
5608
|
+
* (`contain`), so an ancestor's clip/transform/opacity reach it
|
|
5609
|
+
* through the transition; `.group(false)` opts a subject out (`none`)
|
|
5610
|
+
* to stay flat and escape. Skipped for root / pre-named layers, which
|
|
5611
|
+
* aren't elements we resolve and style.
|
|
5612
|
+
*/
|
|
5613
|
+
const group = definition === "root" || !resolveDefs.has(definition)
|
|
5614
|
+
? undefined
|
|
5615
|
+
: flatGroups.has(definition)
|
|
5616
|
+
? "none"
|
|
5617
|
+
: "contain";
|
|
5565
5618
|
let names;
|
|
5566
5619
|
if (definition === "root" || !resolveDefs.has(definition)) {
|
|
5567
5620
|
names = [definition];
|
|
@@ -5574,7 +5627,7 @@ function startViewAnimation(builder) {
|
|
|
5574
5627
|
*/
|
|
5575
5628
|
if (phase === "old") {
|
|
5576
5629
|
pairFrom.set(definition, resolveElements(definition));
|
|
5577
|
-
names = assignViewTransitionNames(definition, nameRegistry, assigned, undefined, className, classed);
|
|
5630
|
+
names = assignViewTransitionNames(definition, nameRegistry, assigned, undefined, className, classed, group, grouped, clipChildren);
|
|
5578
5631
|
pairNames.set(definition, names);
|
|
5579
5632
|
}
|
|
5580
5633
|
else {
|
|
@@ -5594,13 +5647,16 @@ function startViewAnimation(builder) {
|
|
|
5594
5647
|
*/
|
|
5595
5648
|
nameRegistry.delete(el);
|
|
5596
5649
|
}
|
|
5597
|
-
names = assignViewTransitionNames(pairs.get(definition), nameRegistry, assigned, pairNames.get(definition), className, classed);
|
|
5650
|
+
names = assignViewTransitionNames(pairs.get(definition), nameRegistry, assigned, pairNames.get(definition), className, classed, group, grouped, clipChildren);
|
|
5598
5651
|
}
|
|
5599
5652
|
}
|
|
5600
5653
|
else {
|
|
5601
|
-
names = assignViewTransitionNames(definition, nameRegistry, assigned, undefined, className, classed);
|
|
5654
|
+
names = assignViewTransitionNames(definition, nameRegistry, assigned, undefined, className, classed, group, grouped, clipChildren);
|
|
5602
5655
|
}
|
|
5603
|
-
|
|
5656
|
+
// Record any explicit `.crop(true | false)` per resolved name; the
|
|
5657
|
+
// crop set itself is computed later by `finalizeCrop` (it needs both
|
|
5658
|
+
// snapshots to know which morphs change aspect ratio).
|
|
5659
|
+
const override = cropOverride.get(definition);
|
|
5604
5660
|
names.forEach((name, index) => {
|
|
5605
5661
|
/**
|
|
5606
5662
|
* If two subjects resolve to the same element, merge their
|
|
@@ -5610,8 +5666,8 @@ function startViewAnimation(builder) {
|
|
|
5610
5666
|
layerTargets.set(name, existing && existing !== target
|
|
5611
5667
|
? { ...existing, ...target }
|
|
5612
5668
|
: target);
|
|
5613
|
-
if (
|
|
5614
|
-
|
|
5669
|
+
if (override !== undefined)
|
|
5670
|
+
cropForName.set(name, override);
|
|
5615
5671
|
const stagger = layerStagger.get(name) ?? {};
|
|
5616
5672
|
stagger[phase] = [index, names.length];
|
|
5617
5673
|
layerStagger.set(name, stagger);
|
|
@@ -5646,44 +5702,62 @@ function startViewAnimation(builder) {
|
|
|
5646
5702
|
return transition;
|
|
5647
5703
|
};
|
|
5648
5704
|
/**
|
|
5649
|
-
*
|
|
5650
|
-
*
|
|
5651
|
-
* shorthand) so mismatched/individual radii interpolate cleanly.
|
|
5705
|
+
* Each layer's box size per snapshot, so `finalizeCrop` can tell whether a
|
|
5706
|
+
* morph's aspect ratio changed (the only case worth cropping).
|
|
5652
5707
|
*/
|
|
5653
|
-
const
|
|
5654
|
-
const
|
|
5655
|
-
const
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
};
|
|
5708
|
+
const cropBox = new Map();
|
|
5709
|
+
const measureLayers = (phase) => nameRegistry.forEach((name, element) => {
|
|
5710
|
+
const rect = element.getBoundingClientRect?.();
|
|
5711
|
+
if (rect && rect.height) {
|
|
5712
|
+
const entry = cropBox.get(name) ?? {};
|
|
5713
|
+
entry[phase] = { width: rect.width, height: rect.height };
|
|
5714
|
+
cropBox.set(name, entry);
|
|
5715
|
+
}
|
|
5716
|
+
});
|
|
5662
5717
|
/**
|
|
5663
|
-
*
|
|
5664
|
-
*
|
|
5665
|
-
*
|
|
5666
|
-
*
|
|
5718
|
+
* With both snapshots measured, settle which layers crop. The default crops
|
|
5719
|
+
* only a morph whose aspect ratio *changes* between snapshots - the one case
|
|
5720
|
+
* where `object-fit: cover` does real work. A same-aspect morph or a
|
|
5721
|
+
* fade-only layer is left uncropped: its corners scale naturally (no flash
|
|
5722
|
+
* from squaring, no `overflow: clip` eating its shadow) and a backdrop can't
|
|
5723
|
+
* be clipped to nothing. An explicit `.crop(true | false)` overrides either
|
|
5724
|
+
* way. Runs after both snapshots are measured, since aspect needs both.
|
|
5667
5725
|
*/
|
|
5668
|
-
const
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5726
|
+
const finalizeCrop = () => {
|
|
5727
|
+
croppedNames.clear();
|
|
5728
|
+
for (const name of layerStagger.keys()) {
|
|
5729
|
+
if (name === "root")
|
|
5730
|
+
continue;
|
|
5731
|
+
// An explicit `.crop(true | false)` wins; otherwise crop a morph
|
|
5732
|
+
// whose aspect ratio changed.
|
|
5733
|
+
if (cropForName.get(name) ?? aspectChanged(name)) {
|
|
5734
|
+
croppedNames.add(name);
|
|
5674
5735
|
}
|
|
5675
|
-
}
|
|
5736
|
+
}
|
|
5737
|
+
};
|
|
5738
|
+
/**
|
|
5739
|
+
* Whether a layer is a morph whose box aspect ratio changed between
|
|
5740
|
+
* snapshots (beyond a small tolerance). Fade-only layers (one snapshot) are
|
|
5741
|
+
* never "changed".
|
|
5742
|
+
*/
|
|
5743
|
+
const aspectChanged = (name) => {
|
|
5744
|
+
const box = cropBox.get(name);
|
|
5745
|
+
if (!box?.old || !box?.new || !box.old.height || !box.new.height) {
|
|
5746
|
+
return false;
|
|
5747
|
+
}
|
|
5748
|
+
return (Math.abs(box.old.width / box.old.height -
|
|
5749
|
+
box.new.width / box.new.height) > ASPECT_TOLERANCE);
|
|
5676
5750
|
};
|
|
5677
5751
|
/**
|
|
5678
5752
|
* Write the persistent view-transition CSS: suppress root capture when the
|
|
5679
5753
|
* root has no animations of its own; force linear timing (baked into the
|
|
5680
5754
|
* keyframes, so we can retime later via updateTiming); and clip +
|
|
5681
5755
|
* object-fit: cover every cropped morph (the UA default overflows on
|
|
5682
|
-
* aspect-ratio change)
|
|
5756
|
+
* aspect-ratio change).
|
|
5683
5757
|
*
|
|
5684
5758
|
* `css.commit` replaces rather than appends, so we re-set the full rule set
|
|
5685
|
-
* each call - the
|
|
5686
|
-
*
|
|
5759
|
+
* each call - the crop rules are only known after `finalizeCrop` runs in the
|
|
5760
|
+
* update callback, so the second call writes them.
|
|
5687
5761
|
*/
|
|
5688
5762
|
const commitViewCSS = () => {
|
|
5689
5763
|
if (!hasTarget("root", targets)) {
|
|
@@ -5694,33 +5768,49 @@ function startViewAnimation(builder) {
|
|
|
5694
5768
|
css.set(`::view-transition-group(${name})`, { overflow: "clip" });
|
|
5695
5769
|
css.set(`::view-transition-old(${name}), ::view-transition-new(${name})`, { width: "100%", height: "100%", "object-fit": "cover" });
|
|
5696
5770
|
});
|
|
5771
|
+
/**
|
|
5772
|
+
* Clip the nested children of any layer that clips in the live layout,
|
|
5773
|
+
* so a wrapper crops its child for the whole morph (mirroring the DOM)
|
|
5774
|
+
* rather than only at the live-DOM handoff. No-op on browsers without
|
|
5775
|
+
* nested view-transition groups.
|
|
5776
|
+
*/
|
|
5777
|
+
clipChildren.forEach((name) => {
|
|
5778
|
+
css.set(`::view-transition-group-children(${name})`, {
|
|
5779
|
+
overflow: "clip",
|
|
5780
|
+
});
|
|
5781
|
+
});
|
|
5697
5782
|
css.commit(); // Write
|
|
5698
5783
|
};
|
|
5699
5784
|
const cleanup = () => {
|
|
5700
|
-
releaseViewTransitionNames(assigned, classed);
|
|
5785
|
+
releaseViewTransitionNames(assigned, classed, grouped);
|
|
5701
5786
|
css.remove(); // Write
|
|
5702
5787
|
};
|
|
5703
5788
|
const callback = async () => {
|
|
5704
5789
|
await update();
|
|
5705
5790
|
/**
|
|
5706
5791
|
* Re-resolve so elements created by the update are named for the new
|
|
5707
|
-
* snapshot, then measure
|
|
5792
|
+
* snapshot, then measure them. With both snapshots measured we can
|
|
5793
|
+
* settle the crop set (aspect-changing morphs + forced).
|
|
5708
5794
|
*/
|
|
5709
|
-
const croppedBefore = croppedNames.size;
|
|
5710
5795
|
resolveLayers("new");
|
|
5711
|
-
|
|
5796
|
+
measureLayers("new");
|
|
5797
|
+
finalizeCrop();
|
|
5712
5798
|
/**
|
|
5713
|
-
* Re-commit the crop CSS
|
|
5714
|
-
*
|
|
5715
|
-
*
|
|
5799
|
+
* Re-commit the crop CSS unconditionally: `finalizeCrop` is computed
|
|
5800
|
+
* here (after both snapshots are measured), so the clip rules must be
|
|
5801
|
+
* (re)written to match the settled set.
|
|
5716
5802
|
*/
|
|
5717
|
-
|
|
5718
|
-
commitViewCSS();
|
|
5803
|
+
commitViewCSS();
|
|
5719
5804
|
};
|
|
5720
5805
|
let transition;
|
|
5721
5806
|
try {
|
|
5722
5807
|
resolveLayers("old");
|
|
5723
|
-
|
|
5808
|
+
/**
|
|
5809
|
+
* Measure the old snapshot against the optimistic crop set (the new
|
|
5810
|
+
* snapshot doesn't exist yet, so aspect change can't be known here;
|
|
5811
|
+
* `finalizeCrop` settles it post-update).
|
|
5812
|
+
*/
|
|
5813
|
+
measureLayers("old");
|
|
5724
5814
|
commitViewCSS();
|
|
5725
5815
|
transition = document.startViewTransition(callback);
|
|
5726
5816
|
}
|
|
@@ -5895,6 +5985,31 @@ function startViewAnimation(builder) {
|
|
|
5895
5985
|
}
|
|
5896
5986
|
continue;
|
|
5897
5987
|
}
|
|
5988
|
+
/**
|
|
5989
|
+
* Drop the orphaned half of the default crossfade. The UA
|
|
5990
|
+
* fades old out and new in as a *pair*; if the opposing half
|
|
5991
|
+
* was explicitly overridden with something other than an
|
|
5992
|
+
* opacity fade (a clip or transform reveal), this side's
|
|
5993
|
+
* default opacity fade has no partner - left to run it would
|
|
5994
|
+
* dissolve what should be a static backdrop (e.g.
|
|
5995
|
+
* `.new({ clipPath })` should reveal over a still old view,
|
|
5996
|
+
* not fade the old out around the growing clip). Cancel it -
|
|
5997
|
+
* and its `plus-lighter` sibling on the same pseudo, which
|
|
5998
|
+
* would otherwise flash bright where the two opaque layers
|
|
5999
|
+
* overlap. A genuine crossfade (the opposing side also fading
|
|
6000
|
+
* opacity) keeps both halves and is handled above.
|
|
6001
|
+
*/
|
|
6002
|
+
const opposite = name.type === "old"
|
|
6003
|
+
? "new"
|
|
6004
|
+
: name.type === "new"
|
|
6005
|
+
? "old"
|
|
6006
|
+
: undefined;
|
|
6007
|
+
if (opposite &&
|
|
6008
|
+
explicitlyAnimated.has(`${name.layer}:${opposite}`) &&
|
|
6009
|
+
!opacityAnimated.has(`${name.layer}:${opposite}`)) {
|
|
6010
|
+
animation.cancel();
|
|
6011
|
+
continue;
|
|
6012
|
+
}
|
|
5898
6013
|
/**
|
|
5899
6014
|
* Otherwise retime the browser-generated animation to
|
|
5900
6015
|
* Motion's timing. This auto-enables the layout (group)
|
|
@@ -5949,38 +6064,6 @@ function startViewAnimation(builder) {
|
|
|
5949
6064
|
});
|
|
5950
6065
|
animations.push(new NativeAnimationWrapper(animation));
|
|
5951
6066
|
}
|
|
5952
|
-
/**
|
|
5953
|
-
* Animate each cropped layer's clip corners between the old and
|
|
5954
|
-
* new elements, so a cropped morph keeps rounded corners
|
|
5955
|
-
* (handling individual per-corner radii).
|
|
5956
|
-
*/
|
|
5957
|
-
cropRadii.forEach((radii, name) => {
|
|
5958
|
-
if (!radii.old && !radii.new)
|
|
5959
|
-
return;
|
|
5960
|
-
const target = layerTargets.get(name);
|
|
5961
|
-
const [index, total] = staggerPosition(name, "group");
|
|
5962
|
-
const radiusOptions = resolveLayerTransition(target, "group", "layout", index === -1 ? 0 : index, total);
|
|
5963
|
-
radiusOptions.duration && (radiusOptions.duration = motionUtils.secondsToMilliseconds(radiusOptions.duration));
|
|
5964
|
-
radiusOptions.delay && (radiusOptions.delay = motionUtils.secondsToMilliseconds(radiusOptions.delay));
|
|
5965
|
-
for (const corner of cornerProps) {
|
|
5966
|
-
// `||` (not `??`) so an empty measurement (e.g. an
|
|
5967
|
-
// un-rendered element) falls back rather than producing
|
|
5968
|
-
// an invalid keyframe.
|
|
5969
|
-
const from = radii.old?.[corner] || radii.new?.[corner] || "0px";
|
|
5970
|
-
const to = radii.new?.[corner] || radii.old?.[corner] || "0px";
|
|
5971
|
-
// Skip square corners - nothing to round.
|
|
5972
|
-
if (parseFloat(from) === 0 && parseFloat(to) === 0) {
|
|
5973
|
-
continue;
|
|
5974
|
-
}
|
|
5975
|
-
animations.push(new NativeAnimation({
|
|
5976
|
-
...radiusOptions,
|
|
5977
|
-
element: document.documentElement,
|
|
5978
|
-
name: corner,
|
|
5979
|
-
pseudoElement: `::view-transition-group(${name})`,
|
|
5980
|
-
keyframes: [from, to],
|
|
5981
|
-
}));
|
|
5982
|
-
}
|
|
5983
|
-
});
|
|
5984
6067
|
resolve(new GroupAnimation(animations));
|
|
5985
6068
|
})
|
|
5986
6069
|
.catch(() =>
|
|
@@ -6090,10 +6173,12 @@ class ViewTransitionBuilder {
|
|
|
6090
6173
|
*/
|
|
6091
6174
|
this.resolveDefs = new Set();
|
|
6092
6175
|
/**
|
|
6093
|
-
*
|
|
6094
|
-
* animated corner radii)
|
|
6176
|
+
* Per-subject crop override: `true` forces the crop (clip + object-fit:
|
|
6177
|
+
* cover + animated corner radii) on, `false` forces it off. A subject with
|
|
6178
|
+
* no entry uses the default - crop only a genuine morph (a layer present in
|
|
6179
|
+
* both snapshots), so a fade-only enter/exit isn't clipped to nothing.
|
|
6095
6180
|
*/
|
|
6096
|
-
this.
|
|
6181
|
+
this.cropOverride = new Map();
|
|
6097
6182
|
/**
|
|
6098
6183
|
* Subjects paired with a different new-snapshot target (the second `.add()`
|
|
6099
6184
|
* argument), so two distinct elements share one name and morph into each
|
|
@@ -6106,6 +6191,14 @@ class ViewTransitionBuilder {
|
|
|
6106
6191
|
* the opaque generated name.
|
|
6107
6192
|
*/
|
|
6108
6193
|
this.classNames = new Map();
|
|
6194
|
+
/**
|
|
6195
|
+
* Subjects opted out of automatic group nesting via `.group(false)`. Their
|
|
6196
|
+
* layer stays a flat top-level group (`view-transition-group: none`) instead
|
|
6197
|
+
* of nesting under its DOM-ancestor layer - so it animates independently and
|
|
6198
|
+
* escapes an ancestor's clip/transform (e.g. an element that lifts out of a
|
|
6199
|
+
* card and flies across, which nesting would clip to the card).
|
|
6200
|
+
*/
|
|
6201
|
+
this.flatGroups = new Set();
|
|
6109
6202
|
this.notifyReady = motionUtils.noop;
|
|
6110
6203
|
this.notifyReject = motionUtils.noop;
|
|
6111
6204
|
this.readyPromise = new Promise((resolve, reject) => {
|
|
@@ -6143,14 +6236,37 @@ class ViewTransitionBuilder {
|
|
|
6143
6236
|
return this;
|
|
6144
6237
|
}
|
|
6145
6238
|
/**
|
|
6146
|
-
*
|
|
6147
|
-
*
|
|
6148
|
-
*
|
|
6239
|
+
* Control this subject's crop (clip + `object-fit: cover` + animated
|
|
6240
|
+
* corners). By default a subject auto-crops only when it actually morphs -
|
|
6241
|
+
* present in both snapshots (a survivor, or an `.add(a, b)` pair). A
|
|
6242
|
+
* fade-only enter/exit has no second box to crop against, so it's left to
|
|
6243
|
+
* the browser default; in particular the `overflow: clip` a crop adds would
|
|
6244
|
+
* otherwise clip a mis-sized enter/exit layer to nothing.
|
|
6245
|
+
*
|
|
6246
|
+
* `.crop(false)` forces the crop off (e.g. a text morph, where
|
|
6247
|
+
* `object-fit: cover` clips glyphs as the box grows); `.crop(true)` forces
|
|
6248
|
+
* it on for a non-morph the default wouldn't otherwise crop.
|
|
6149
6249
|
*/
|
|
6150
6250
|
crop(enabled = true) {
|
|
6251
|
+
this.cropOverride.set(this.currentSubject, enabled);
|
|
6252
|
+
return this;
|
|
6253
|
+
}
|
|
6254
|
+
/**
|
|
6255
|
+
* By default a subject's layer nests under its nearest DOM-ancestor layer
|
|
6256
|
+
* (`view-transition-group: contain`), so the ancestor's clip/transform/opacity
|
|
6257
|
+
* apply to it through the transition - mirroring how the DOM actually paints,
|
|
6258
|
+
* and letting a wrapper crop its child for the whole morph rather than only
|
|
6259
|
+
* once the live DOM takes back over. (Needs a browser that supports nested
|
|
6260
|
+
* view-transition groups; elsewhere it degrades to the flat default.)
|
|
6261
|
+
*
|
|
6262
|
+
* Call `.group(false)` to opt out: the layer stays flat and top-level, so it
|
|
6263
|
+
* animates independently and escapes an ancestor's clip - e.g. an element
|
|
6264
|
+
* that should lift out of a card and fly across, which nesting would clip.
|
|
6265
|
+
*/
|
|
6266
|
+
group(enabled = true) {
|
|
6151
6267
|
enabled
|
|
6152
|
-
? this.
|
|
6153
|
-
: this.
|
|
6268
|
+
? this.flatGroups.delete(this.currentSubject)
|
|
6269
|
+
: this.flatGroups.add(this.currentSubject);
|
|
6154
6270
|
return this;
|
|
6155
6271
|
}
|
|
6156
6272
|
/**
|