motion-dom 12.40.0 → 12.42.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/cjs/index.js +1114 -458
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +0 -3
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/start-waapi-animation.mjs +1 -12
- package/dist/es/animation/waapi/start-waapi-animation.mjs.map +1 -1
- package/dist/es/events/add-dom-event.mjs +1 -1
- package/dist/es/events/add-dom-event.mjs.map +1 -1
- package/dist/es/frameloop/batcher.mjs +1 -1
- package/dist/es/frameloop/batcher.mjs.map +1 -1
- package/dist/es/frameloop/render-step.mjs +1 -12
- package/dist/es/frameloop/render-step.mjs.map +1 -1
- package/dist/es/gestures/press/index.mjs +11 -4
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/index.mjs +0 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +299 -214
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +0 -6
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/stats/buffer.mjs.map +1 -1
- package/dist/es/stats/index.mjs +4 -93
- package/dist/es/stats/index.mjs.map +1 -1
- package/dist/es/view/index.mjs +123 -13
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/es/view/queue.mjs +9 -3
- package/dist/es/view/queue.mjs.map +1 -1
- package/dist/es/view/start.mjs +514 -83
- package/dist/es/view/start.mjs.map +1 -1
- package/dist/es/view/utils/assign-names.mjs +146 -0
- package/dist/es/view/utils/assign-names.mjs.map +1 -0
- package/dist/es/view/utils/choose-layer-type.mjs +1 -3
- package/dist/es/view/utils/choose-layer-type.mjs.map +1 -1
- package/dist/es/view/utils/get-layer-info.mjs +3 -1
- package/dist/es/view/utils/get-layer-info.mjs.map +1 -1
- package/dist/es/view/utils/get-view-animations.mjs +6 -8
- package/dist/es/view/utils/get-view-animations.mjs.map +1 -1
- package/dist/index.d.ts +135 -52
- package/dist/motion-dom.dev.js +1114 -458
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
- package/dist/es/stats/animation-count.mjs +0 -8
- package/dist/es/stats/animation-count.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.mjs","sources":["../../../src/stats/buffer.ts"],"sourcesContent":["import type { StatsRecording } from \"./types\"\n\nexport type InactiveStatsBuffer = {\n value: null\n addProjectionMetrics: null\n}\n\nexport type ActiveStatsBuffer = {\n value: StatsRecording\n addProjectionMetrics: (metrics:
|
|
1
|
+
{"version":3,"file":"buffer.mjs","sources":["../../../src/stats/buffer.ts"],"sourcesContent":["import type { LayoutProjectionMetrics, StatsRecording } from \"./types\"\n\nexport type InactiveStatsBuffer = {\n value: null\n addProjectionMetrics: null\n}\n\nexport type ActiveStatsBuffer = {\n value: StatsRecording\n addProjectionMetrics: (metrics: LayoutProjectionMetrics) => void\n}\n\nexport const statsBuffer: InactiveStatsBuffer | ActiveStatsBuffer = {\n value: null,\n addProjectionMetrics: null,\n}\n"],"names":[],"mappings":"AAYO,MAAM,WAAW,GAA4C;AAChE,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,oBAAoB,EAAE,IAAI;;;;;"}
|
package/dist/es/stats/index.mjs
CHANGED
|
@@ -1,117 +1,28 @@
|
|
|
1
|
-
import { activeAnimations } from './animation-count.mjs';
|
|
2
1
|
import { statsBuffer } from './buffer.mjs';
|
|
3
|
-
import { frame, cancelFrame, frameData } from '../frameloop/frame.mjs';
|
|
4
2
|
|
|
5
|
-
function record() {
|
|
6
|
-
const { value } = statsBuffer;
|
|
7
|
-
if (value === null) {
|
|
8
|
-
cancelFrame(record);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
value.frameloop.rate.push(frameData.delta);
|
|
12
|
-
value.animations.mainThread.push(activeAnimations.mainThread);
|
|
13
|
-
value.animations.waapi.push(activeAnimations.waapi);
|
|
14
|
-
value.animations.layout.push(activeAnimations.layout);
|
|
15
|
-
}
|
|
16
|
-
function mean(values) {
|
|
17
|
-
return values.reduce((acc, value) => acc + value, 0) / values.length;
|
|
18
|
-
}
|
|
19
|
-
function summarise(values, calcAverage = mean) {
|
|
20
|
-
if (values.length === 0) {
|
|
21
|
-
return {
|
|
22
|
-
min: 0,
|
|
23
|
-
max: 0,
|
|
24
|
-
avg: 0,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
min: Math.min(...values),
|
|
29
|
-
max: Math.max(...values),
|
|
30
|
-
avg: calcAverage(values),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const msToFps = (ms) => Math.round(1000 / ms);
|
|
34
3
|
function clearStatsBuffer() {
|
|
35
4
|
statsBuffer.value = null;
|
|
36
5
|
statsBuffer.addProjectionMetrics = null;
|
|
37
6
|
}
|
|
38
|
-
function reportStats() {
|
|
39
|
-
const { value } = statsBuffer;
|
|
40
|
-
if (!value) {
|
|
41
|
-
throw new Error("Stats are not being measured");
|
|
42
|
-
}
|
|
43
|
-
clearStatsBuffer();
|
|
44
|
-
cancelFrame(record);
|
|
45
|
-
const summary = {
|
|
46
|
-
frameloop: {
|
|
47
|
-
setup: summarise(value.frameloop.setup),
|
|
48
|
-
rate: summarise(value.frameloop.rate),
|
|
49
|
-
read: summarise(value.frameloop.read),
|
|
50
|
-
resolveKeyframes: summarise(value.frameloop.resolveKeyframes),
|
|
51
|
-
preUpdate: summarise(value.frameloop.preUpdate),
|
|
52
|
-
update: summarise(value.frameloop.update),
|
|
53
|
-
preRender: summarise(value.frameloop.preRender),
|
|
54
|
-
render: summarise(value.frameloop.render),
|
|
55
|
-
postRender: summarise(value.frameloop.postRender),
|
|
56
|
-
},
|
|
57
|
-
animations: {
|
|
58
|
-
mainThread: summarise(value.animations.mainThread),
|
|
59
|
-
waapi: summarise(value.animations.waapi),
|
|
60
|
-
layout: summarise(value.animations.layout),
|
|
61
|
-
},
|
|
62
|
-
layoutProjection: {
|
|
63
|
-
nodes: summarise(value.layoutProjection.nodes),
|
|
64
|
-
calculatedTargetDeltas: summarise(value.layoutProjection.calculatedTargetDeltas),
|
|
65
|
-
calculatedProjections: summarise(value.layoutProjection.calculatedProjections),
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Convert the rate to FPS
|
|
70
|
-
*/
|
|
71
|
-
const { rate } = summary.frameloop;
|
|
72
|
-
rate.min = msToFps(rate.min);
|
|
73
|
-
rate.max = msToFps(rate.max);
|
|
74
|
-
rate.avg = msToFps(rate.avg);
|
|
75
|
-
[rate.min, rate.max] = [rate.max, rate.min];
|
|
76
|
-
return summary;
|
|
77
|
-
}
|
|
78
7
|
function recordStats() {
|
|
79
8
|
if (statsBuffer.value) {
|
|
80
9
|
clearStatsBuffer();
|
|
81
10
|
throw new Error("Stats are already being measured");
|
|
82
11
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
frameloop: {
|
|
86
|
-
setup: [],
|
|
87
|
-
rate: [],
|
|
88
|
-
read: [],
|
|
89
|
-
resolveKeyframes: [],
|
|
90
|
-
preUpdate: [],
|
|
91
|
-
update: [],
|
|
92
|
-
preRender: [],
|
|
93
|
-
render: [],
|
|
94
|
-
postRender: [],
|
|
95
|
-
},
|
|
96
|
-
animations: {
|
|
97
|
-
mainThread: [],
|
|
98
|
-
waapi: [],
|
|
99
|
-
layout: [],
|
|
100
|
-
},
|
|
12
|
+
const buffer = statsBuffer;
|
|
13
|
+
buffer.value = {
|
|
101
14
|
layoutProjection: {
|
|
102
15
|
nodes: [],
|
|
103
16
|
calculatedTargetDeltas: [],
|
|
104
17
|
calculatedProjections: [],
|
|
105
18
|
},
|
|
106
19
|
};
|
|
107
|
-
|
|
108
|
-
const { layoutProjection } =
|
|
20
|
+
buffer.addProjectionMetrics = (metrics) => {
|
|
21
|
+
const { layoutProjection } = buffer.value;
|
|
109
22
|
layoutProjection.nodes.push(metrics.nodes);
|
|
110
23
|
layoutProjection.calculatedTargetDeltas.push(metrics.calculatedTargetDeltas);
|
|
111
24
|
layoutProjection.calculatedProjections.push(metrics.calculatedProjections);
|
|
112
25
|
};
|
|
113
|
-
frame.postRender(record, true);
|
|
114
|
-
return reportStats;
|
|
115
26
|
}
|
|
116
27
|
|
|
117
28
|
export { recordStats };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/stats/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/stats/index.ts"],"sourcesContent":["import { ActiveStatsBuffer, statsBuffer } from \"./buffer\"\n\nfunction clearStatsBuffer() {\n statsBuffer.value = null\n statsBuffer.addProjectionMetrics = null\n}\n\nexport function recordStats() {\n if (statsBuffer.value) {\n clearStatsBuffer()\n throw new Error(\"Stats are already being measured\")\n }\n\n const buffer = statsBuffer as unknown as ActiveStatsBuffer\n\n buffer.value = {\n layoutProjection: {\n nodes: [],\n calculatedTargetDeltas: [],\n calculatedProjections: [],\n },\n }\n\n buffer.addProjectionMetrics = (metrics) => {\n const { layoutProjection } = buffer.value\n layoutProjection.nodes.push(metrics.nodes)\n layoutProjection.calculatedTargetDeltas.push(\n metrics.calculatedTargetDeltas\n )\n layoutProjection.calculatedProjections.push(\n metrics.calculatedProjections\n )\n }\n}\n"],"names":[],"mappings":";;AAEA,SAAS,gBAAgB,GAAA;AACrB,IAAA,WAAW,CAAC,KAAK,GAAG,IAAI;AACxB,IAAA,WAAW,CAAC,oBAAoB,GAAG,IAAI;AAC3C;SAEgB,WAAW,GAAA;AACvB,IAAA,IAAI,WAAW,CAAC,KAAK,EAAE;AACnB,QAAA,gBAAgB,EAAE;AAClB,QAAA,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC;IACvD;IAEA,MAAM,MAAM,GAAG,WAA2C;IAE1D,MAAM,CAAC,KAAK,GAAG;AACX,QAAA,gBAAgB,EAAE;AACd,YAAA,KAAK,EAAE,EAAE;AACT,YAAA,sBAAsB,EAAE,EAAE;AAC1B,YAAA,qBAAqB,EAAE,EAAE;AAC5B,SAAA;KACJ;AAED,IAAA,MAAM,CAAC,oBAAoB,GAAG,CAAC,OAAO,KAAI;AACtC,QAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,KAAK;QACzC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1C,gBAAgB,CAAC,sBAAsB,CAAC,IAAI,CACxC,OAAO,CAAC,sBAAsB,CACjC;QACD,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,CACvC,OAAO,CAAC,qBAAqB,CAChC;AACL,IAAA,CAAC;AACL;;;;"}
|
package/dist/es/view/index.mjs
CHANGED
|
@@ -5,31 +5,129 @@ class ViewTransitionBuilder {
|
|
|
5
5
|
constructor(update, options = {}) {
|
|
6
6
|
this.currentSubject = "root";
|
|
7
7
|
this.targets = new Map();
|
|
8
|
+
/**
|
|
9
|
+
* Definitions that must be resolved to elements (and assigned a
|
|
10
|
+
* `view-transition-name`) rather than treated as pre-named layers.
|
|
11
|
+
*/
|
|
12
|
+
this.resolveDefs = new Set();
|
|
13
|
+
/**
|
|
14
|
+
* Per-subject crop override: `true` forces the crop (clip + object-fit:
|
|
15
|
+
* cover + animated corner radii) on, `false` forces it off. A subject with
|
|
16
|
+
* no entry uses the default - crop only a genuine morph (a layer present in
|
|
17
|
+
* both snapshots), so a fade-only enter/exit isn't clipped to nothing.
|
|
18
|
+
*/
|
|
19
|
+
this.cropOverride = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* Subjects paired with a different new-snapshot target (the second `.add()`
|
|
22
|
+
* argument), so two distinct elements share one name and morph into each
|
|
23
|
+
* other - a shared-element transition.
|
|
24
|
+
*/
|
|
25
|
+
this.pairs = new Map();
|
|
26
|
+
/**
|
|
27
|
+
* A `view-transition-class` to apply to each subject's resolved elements,
|
|
28
|
+
* so authors can target the generated layers from CSS by class rather than
|
|
29
|
+
* the opaque generated name.
|
|
30
|
+
*/
|
|
31
|
+
this.classNames = new Map();
|
|
32
|
+
/**
|
|
33
|
+
* Subjects opted out of automatic group nesting via `.group(false)`. Their
|
|
34
|
+
* layer stays a flat top-level group (`view-transition-group: none`) instead
|
|
35
|
+
* of nesting under its DOM-ancestor layer - so it animates independently and
|
|
36
|
+
* escapes an ancestor's clip/transform (e.g. an element that lifts out of a
|
|
37
|
+
* card and flies across, which nesting would clip to the card).
|
|
38
|
+
*/
|
|
39
|
+
this.flatGroups = new Set();
|
|
8
40
|
this.notifyReady = noop;
|
|
9
|
-
this.
|
|
41
|
+
this.notifyReject = noop;
|
|
42
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
10
43
|
this.notifyReady = resolve;
|
|
44
|
+
this.notifyReject = reject;
|
|
11
45
|
});
|
|
12
46
|
this.update = update;
|
|
13
47
|
this.options = {
|
|
14
48
|
interrupt: "wait",
|
|
15
49
|
...options,
|
|
16
50
|
};
|
|
51
|
+
// Avoid an unhandled rejection when a failed transition has no
|
|
52
|
+
// `.then(_, reject)` handler attached (e.g. fire-and-forget).
|
|
53
|
+
this.readyPromise.catch(noop);
|
|
17
54
|
addToQueue(this);
|
|
18
55
|
}
|
|
19
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Target elements resolved from a selector or Element, each assigned a
|
|
58
|
+
* `view-transition-name` automatically.
|
|
59
|
+
*
|
|
60
|
+
* Passing a second target pairs them: the first is resolved in the old
|
|
61
|
+
* snapshot and the second in the new, sharing one name so two *different*
|
|
62
|
+
* elements morph into each other (e.g. `.add(card, ".modal")`). Symmetric -
|
|
63
|
+
* pass them the other way round to morph back.
|
|
64
|
+
*/
|
|
65
|
+
add(subject, newSubject) {
|
|
20
66
|
this.currentSubject = subject;
|
|
67
|
+
this.resolveDefs.add(subject);
|
|
68
|
+
if (newSubject !== undefined)
|
|
69
|
+
this.pairs.set(subject, newSubject);
|
|
70
|
+
// Register the subject so it participates (and gets an automatic
|
|
71
|
+
// layout/morph animation) even without an explicit enter/exit/layout.
|
|
72
|
+
if (!this.targets.has(subject))
|
|
73
|
+
this.targets.set(subject, {});
|
|
21
74
|
return this;
|
|
22
75
|
}
|
|
23
|
-
|
|
24
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Control this subject's crop (clip + `object-fit: cover` + animated
|
|
78
|
+
* corners). By default a subject auto-crops only when it actually morphs -
|
|
79
|
+
* present in both snapshots (a survivor, or an `.add(a, b)` pair). A
|
|
80
|
+
* fade-only enter/exit has no second box to crop against, so it's left to
|
|
81
|
+
* the browser default; in particular the `overflow: clip` a crop adds would
|
|
82
|
+
* otherwise clip a mis-sized enter/exit layer to nothing.
|
|
83
|
+
*
|
|
84
|
+
* `.crop(false)` forces the crop off (e.g. a text morph, where
|
|
85
|
+
* `object-fit: cover` clips glyphs as the box grows); `.crop(true)` forces
|
|
86
|
+
* it on for a non-morph the default wouldn't otherwise crop.
|
|
87
|
+
*/
|
|
88
|
+
crop(enabled = true) {
|
|
89
|
+
this.cropOverride.set(this.currentSubject, enabled);
|
|
25
90
|
return this;
|
|
26
91
|
}
|
|
27
|
-
|
|
28
|
-
|
|
92
|
+
/**
|
|
93
|
+
* By default a subject's layer nests under its nearest DOM-ancestor layer
|
|
94
|
+
* (`view-transition-group: contain`), so the ancestor's clip/transform/opacity
|
|
95
|
+
* apply to it through the transition - mirroring how the DOM actually paints,
|
|
96
|
+
* and letting a wrapper crop its child for the whole morph rather than only
|
|
97
|
+
* once the live DOM takes back over. (Needs a browser that supports nested
|
|
98
|
+
* view-transition groups; elsewhere it degrades to the flat default.)
|
|
99
|
+
*
|
|
100
|
+
* Call `.group(false)` to opt out: the layer stays flat and top-level, so it
|
|
101
|
+
* animates independently and escapes an ancestor's clip - e.g. an element
|
|
102
|
+
* that should lift out of a card and fly across, which nesting would clip.
|
|
103
|
+
*/
|
|
104
|
+
group(enabled = true) {
|
|
105
|
+
enabled
|
|
106
|
+
? this.flatGroups.delete(this.currentSubject)
|
|
107
|
+
: this.flatGroups.add(this.currentSubject);
|
|
29
108
|
return this;
|
|
30
109
|
}
|
|
31
|
-
|
|
32
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Tag this subject's generated layers with a `view-transition-class`, so
|
|
112
|
+
* they can be targeted from CSS - `::view-transition-group(.name)`,
|
|
113
|
+
* `::view-transition-old/new(.name)`, `::view-transition-image-pair(.name)`
|
|
114
|
+
* - without the opaque generated `view-transition-name`. Because `.add()`
|
|
115
|
+
* can match many elements, a shared class targets them all at once (and,
|
|
116
|
+
* for a pair, both ends). The escape hatch for z-index / custom keyframes
|
|
117
|
+
* on a morph layer.
|
|
118
|
+
*/
|
|
119
|
+
class(name) {
|
|
120
|
+
this.classNames.set(this.currentSubject, name);
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Set the transition for this subject's morph. The morph is enabled
|
|
125
|
+
* automatically by `.add()`; this just customises its timing (duration,
|
|
126
|
+
* easing, a `delay`/`stagger`, …). On the implicit `root` subject it also
|
|
127
|
+
* opts the page into the transition (the root crossfade).
|
|
128
|
+
*/
|
|
129
|
+
layout(options = {}) {
|
|
130
|
+
this.updateTarget("layout", {}, options);
|
|
33
131
|
return this;
|
|
34
132
|
}
|
|
35
133
|
enter(keyframes, options) {
|
|
@@ -40,9 +138,21 @@ class ViewTransitionBuilder {
|
|
|
40
138
|
this.updateTarget("exit", keyframes, options);
|
|
41
139
|
return this;
|
|
42
140
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Animate the new view directly, whether the element is appearing or
|
|
143
|
+
* persisting (unlike `.enter()`, which only fires for a pure newcomer).
|
|
144
|
+
* Pair with `.old()` for a crossfade or slide-through.
|
|
145
|
+
*/
|
|
146
|
+
new(keyframes, options) {
|
|
147
|
+
this.updateTarget("new", keyframes, options);
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Animate the old view directly, whether the element is leaving or
|
|
152
|
+
* persisting (unlike `.exit()`, which only fires for a pure leaver).
|
|
153
|
+
*/
|
|
154
|
+
old(keyframes, options) {
|
|
155
|
+
this.updateTarget("old", keyframes, options);
|
|
46
156
|
return this;
|
|
47
157
|
}
|
|
48
158
|
updateTarget(target, keyframes, options = {}) {
|
|
@@ -57,8 +167,8 @@ class ViewTransitionBuilder {
|
|
|
57
167
|
return this.readyPromise.then(resolve, reject);
|
|
58
168
|
}
|
|
59
169
|
}
|
|
60
|
-
function animateView(update,
|
|
61
|
-
return new ViewTransitionBuilder(update,
|
|
170
|
+
function animateView(update, options = {}) {
|
|
171
|
+
return new ViewTransitionBuilder(update, options);
|
|
62
172
|
}
|
|
63
173
|
|
|
64
174
|
export { ViewTransitionBuilder, animateView };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/view/index.ts"],"sourcesContent":["import { noop } from \"motion-utils\"\nimport type { GroupAnimation } from \"../animation/GroupAnimation\"\nimport { AnimationOptions, DOMKeyframesDefinition } from \"../animation/types\"\nimport { addToQueue } from \"./queue\"\nimport {\n ViewTransitionOptions,\n ViewTransitionTarget,\n ViewTransitionTargetDefinition,\n} from \"./types\"\nimport \"./types.global\"\n\nexport class ViewTransitionBuilder {\n private currentSubject: ViewTransitionTargetDefinition = \"root\"\n\n targets = new Map<ViewTransitionTargetDefinition, ViewTransitionTarget>()\n\n update: () => void | Promise<void>\n\n options: ViewTransitionOptions\n\n notifyReady: (value: GroupAnimation) => void = noop\n\n private readyPromise = new Promise<GroupAnimation>((resolve) => {\n this.notifyReady = resolve\n })\n\n constructor(\n update: () => void | Promise<void>,\n options: ViewTransitionOptions = {}\n ) {\n this.update = update\n this.options = {\n interrupt: \"wait\",\n ...options,\n }\n addToQueue(this)\n }\n\n get(subject: ViewTransitionTargetDefinition) {\n this.currentSubject = subject\n\n return this\n }\n\n layout(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"layout\", keyframes, options)\n\n return this\n }\n\n new(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"new\", keyframes, options)\n\n return this\n }\n\n old(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"old\", keyframes, options)\n\n return this\n }\n\n enter(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"enter\", keyframes, options)\n\n return this\n }\n\n exit(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"exit\", keyframes, options)\n\n return this\n }\n\n crossfade(options?: AnimationOptions) {\n this.updateTarget(\"enter\", { opacity: 1 }, options)\n this.updateTarget(\"exit\", { opacity: 0 }, options)\n\n return this\n }\n\n updateTarget(\n target: \"enter\" | \"exit\" | \"layout\" | \"new\" | \"old\",\n keyframes: DOMKeyframesDefinition,\n options: AnimationOptions = {}\n ) {\n const { currentSubject, targets } = this\n\n if (!targets.has(currentSubject)) {\n targets.set(currentSubject, {})\n }\n\n const targetData = targets.get(currentSubject)!\n\n targetData[target] = { keyframes, options }\n }\n\n then(resolve: () => void, reject?: () => void) {\n return this.readyPromise.then(resolve, reject)\n }\n}\n\nexport function animateView(\n update: () => void | Promise<void>,\n defaultOptions: ViewTransitionOptions = {}\n) {\n return new ViewTransitionBuilder(update, defaultOptions)\n}\n"],"names":[],"mappings":";;;MAWa,qBAAqB,CAAA;IAe9B,WAAA,CACI,MAAkC,EAClC,OAAA,GAAiC,EAAE,EAAA;QAhB/B,IAAA,CAAA,cAAc,GAAmC,MAAM;AAE/D,QAAA,IAAA,CAAA,OAAO,GAAG,IAAI,GAAG,EAAwD;QAMzE,IAAA,CAAA,WAAW,GAAoC,IAAI;AAE3C,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,OAAO,CAAiB,C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CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,CAAC;AAElD,QAAA,OAAO,IAAI;IACf;AAEA,IAAA,YAAY,CACR,MAAmD,EACnD,SAAiC,EACjC,UAA4B,EAAE,EAAA;AAE9B,QAAA,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;QAExC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;AAC9B,YAAA,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC;QACnC;QAEA,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE;QAE/C,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE;IAC/C;IAEA,IAAI,CAAC,OAAmB,EAAE,MAAmB,EAAA;QACzC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;IAClD;AACH;SAEe,WAAW,CACvB,MAAkC,EAClC,iBAAwC,EAAE,EAAA;AAE1C,IAAA,OAAO,IAAI,qBAAqB,CAAC,MAAM,EAAE,cAAc,CAAC;AAC5D;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/view/index.ts"],"sourcesContent":["import { noop } from \"motion-utils\"\nimport type { GroupAnimation } from \"../animation/GroupAnimation\"\nimport { AnimationOptions, DOMKeyframesDefinition } from \"../animation/types\"\nimport { addToQueue } from \"./queue\"\nimport {\n ViewTransitionOptions,\n ViewTransitionTarget,\n ViewTransitionTargetDefinition,\n} from \"./types\"\nimport \"./types.global\"\n\n// Re-export the public view-transition types so they flow out through\n// motion-dom -> framer-motion -> motion alongside `animateView`.\nexport type * from \"./types\"\n\nexport class ViewTransitionBuilder {\n private currentSubject: ViewTransitionTargetDefinition = \"root\"\n\n targets = new Map<ViewTransitionTargetDefinition, ViewTransitionTarget>()\n\n /**\n * Definitions that must be resolved to elements (and assigned a\n * `view-transition-name`) rather than treated as pre-named layers.\n */\n resolveDefs = new Set<ViewTransitionTargetDefinition>()\n\n /**\n * Per-subject crop override: `true` forces the crop (clip + object-fit:\n * cover + animated corner radii) on, `false` forces it off. A subject with\n * no entry uses the default - crop only a genuine morph (a layer present in\n * both snapshots), so a fade-only enter/exit isn't clipped to nothing.\n */\n cropOverride = new Map<ViewTransitionTargetDefinition, boolean>()\n\n /**\n * Subjects paired with a different new-snapshot target (the second `.add()`\n * argument), so two distinct elements share one name and morph into each\n * other - a shared-element transition.\n */\n pairs = new Map<\n ViewTransitionTargetDefinition,\n ViewTransitionTargetDefinition\n >()\n\n /**\n * A `view-transition-class` to apply to each subject's resolved elements,\n * so authors can target the generated layers from CSS by class rather than\n * the opaque generated name.\n */\n classNames = new Map<ViewTransitionTargetDefinition, string>()\n\n /**\n * Subjects opted out of automatic group nesting via `.group(false)`. Their\n * layer stays a flat top-level group (`view-transition-group: none`) instead\n * of nesting under its DOM-ancestor layer - so it animates independently and\n * escapes an ancestor's clip/transform (e.g. an element that lifts out of a\n * card and flies across, which nesting would clip to the card).\n */\n flatGroups = new Set<ViewTransitionTargetDefinition>()\n\n update: () => void | Promise<void>\n\n options: ViewTransitionOptions\n\n notifyReady: (value: GroupAnimation) => void = noop\n\n notifyReject: (error: unknown) => void = noop\n\n private readyPromise = new Promise<GroupAnimation>((resolve, reject) => {\n this.notifyReady = resolve\n this.notifyReject = reject\n })\n\n constructor(\n update: () => void | Promise<void>,\n options: ViewTransitionOptions = {}\n ) {\n this.update = update\n this.options = {\n interrupt: \"wait\",\n ...options,\n }\n // Avoid an unhandled rejection when a failed transition has no\n // `.then(_, reject)` handler attached (e.g. fire-and-forget).\n this.readyPromise.catch(noop)\n addToQueue(this)\n }\n\n /**\n * Target elements resolved from a selector or Element, each assigned a\n * `view-transition-name` automatically.\n *\n * Passing a second target pairs them: the first is resolved in the old\n * snapshot and the second in the new, sharing one name so two *different*\n * elements morph into each other (e.g. `.add(card, \".modal\")`). Symmetric -\n * pass them the other way round to morph back.\n */\n add(\n subject: ViewTransitionTargetDefinition,\n newSubject?: ViewTransitionTargetDefinition\n ) {\n this.currentSubject = subject\n this.resolveDefs.add(subject)\n if (newSubject !== undefined) this.pairs.set(subject, newSubject)\n // Register the subject so it participates (and gets an automatic\n // layout/morph animation) even without an explicit enter/exit/layout.\n if (!this.targets.has(subject)) this.targets.set(subject, {})\n\n return this\n }\n\n /**\n * Control this subject's crop (clip + `object-fit: cover` + animated\n * corners). By default a subject auto-crops only when it actually morphs -\n * present in both snapshots (a survivor, or an `.add(a, b)` pair). A\n * fade-only enter/exit has no second box to crop against, so it's left to\n * the browser default; in particular the `overflow: clip` a crop adds would\n * otherwise clip a mis-sized enter/exit layer to nothing.\n *\n * `.crop(false)` forces the crop off (e.g. a text morph, where\n * `object-fit: cover` clips glyphs as the box grows); `.crop(true)` forces\n * it on for a non-morph the default wouldn't otherwise crop.\n */\n crop(enabled = true) {\n this.cropOverride.set(this.currentSubject, enabled)\n\n return this\n }\n\n /**\n * By default a subject's layer nests under its nearest DOM-ancestor layer\n * (`view-transition-group: contain`), so the ancestor's clip/transform/opacity\n * apply to it through the transition - mirroring how the DOM actually paints,\n * and letting a wrapper crop its child for the whole morph rather than only\n * once the live DOM takes back over. (Needs a browser that supports nested\n * view-transition groups; elsewhere it degrades to the flat default.)\n *\n * Call `.group(false)` to opt out: the layer stays flat and top-level, so it\n * animates independently and escapes an ancestor's clip - e.g. an element\n * that should lift out of a card and fly across, which nesting would clip.\n */\n group(enabled = true) {\n enabled\n ? this.flatGroups.delete(this.currentSubject)\n : this.flatGroups.add(this.currentSubject)\n\n return this\n }\n\n /**\n * Tag this subject's generated layers with a `view-transition-class`, so\n * they can be targeted from CSS - `::view-transition-group(.name)`,\n * `::view-transition-old/new(.name)`, `::view-transition-image-pair(.name)`\n * - without the opaque generated `view-transition-name`. Because `.add()`\n * can match many elements, a shared class targets them all at once (and,\n * for a pair, both ends). The escape hatch for z-index / custom keyframes\n * on a morph layer.\n */\n class(name: string) {\n this.classNames.set(this.currentSubject, name)\n\n return this\n }\n\n /**\n * Set the transition for this subject's morph. The morph is enabled\n * automatically by `.add()`; this just customises its timing (duration,\n * easing, a `delay`/`stagger`, …). On the implicit `root` subject it also\n * opts the page into the transition (the root crossfade).\n */\n layout(options: AnimationOptions = {}) {\n this.updateTarget(\"layout\", {}, options)\n\n return this\n }\n\n enter(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"enter\", keyframes, options)\n\n return this\n }\n\n exit(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"exit\", keyframes, options)\n\n return this\n }\n\n /**\n * Animate the new view directly, whether the element is appearing or\n * persisting (unlike `.enter()`, which only fires for a pure newcomer).\n * Pair with `.old()` for a crossfade or slide-through.\n */\n new(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"new\", keyframes, options)\n\n return this\n }\n\n /**\n * Animate the old view directly, whether the element is leaving or\n * persisting (unlike `.exit()`, which only fires for a pure leaver).\n */\n old(keyframes: DOMKeyframesDefinition, options?: AnimationOptions) {\n this.updateTarget(\"old\", keyframes, options)\n\n return this\n }\n\n updateTarget(\n target: \"enter\" | \"exit\" | \"layout\" | \"new\" | \"old\",\n keyframes: DOMKeyframesDefinition,\n options: AnimationOptions = {}\n ) {\n const { currentSubject, targets } = this\n\n if (!targets.has(currentSubject)) {\n targets.set(currentSubject, {})\n }\n\n const targetData = targets.get(currentSubject)!\n\n targetData[target] = { keyframes, options }\n }\n\n then(resolve: () => void, reject?: () => void) {\n return this.readyPromise.then(resolve, reject)\n }\n}\n\nexport function animateView(\n update: () => void | Promise<void>,\n options: ViewTransitionOptions = {}\n) {\n return new ViewTransitionBuilder(update, options)\n}\n"],"names":[],"mappings":";;;MAea,qBAAqB,CAAA;IA0D9B,WAAA,CACI,MAAkC,EAClC,OAAA,GAAiC,EAAE,EAAA;QA3D/B,IAAA,CAAA,cAAc,GAAmC,MAAM;AA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,QAAA,OAAO,IAAI;IACf;AAEA;;;AAGG;IACH,GAAG,CAAC,SAAiC,EAAE,OAA0B,EAAA;QAC7D,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC;AAE5C,QAAA,OAAO,IAAI;IACf;AAEA,IAAA,YAAY,CACR,MAAmD,EACnD,SAAiC,EACjC,UAA4B,EAAE,EAAA;AAE9B,QAAA,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;QAExC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;AAC9B,YAAA,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC;QACnC;QAEA,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE;QAE/C,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE;IAC/C;IAEA,IAAI,CAAC,OAAmB,EAAE,MAAmB,EAAA;QACzC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;IAClD;AACH;SAEe,WAAW,CACvB,MAAkC,EAClC,UAAiC,EAAE,EAAA;AAEnC,IAAA,OAAO,IAAI,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC;AACrD;;;;"}
|
package/dist/es/view/queue.mjs
CHANGED
|
@@ -13,10 +13,16 @@ function next() {
|
|
|
13
13
|
function start(builder) {
|
|
14
14
|
removeItem(builders, builder);
|
|
15
15
|
current = builder;
|
|
16
|
-
startViewAnimation(builder)
|
|
16
|
+
startViewAnimation(builder)
|
|
17
|
+
.then((animation) => {
|
|
17
18
|
builder.notifyReady(animation);
|
|
18
|
-
animation.finished
|
|
19
|
-
})
|
|
19
|
+
return animation.finished;
|
|
20
|
+
})
|
|
21
|
+
// A genuinely failed transition (a throwing update) rejects the
|
|
22
|
+
// builder; a skipped/interrupted one resolves with no animations (see
|
|
23
|
+
// start.ts). Either way, advance the queue - else later transitions hang.
|
|
24
|
+
.catch((error) => builder.notifyReject(error))
|
|
25
|
+
.finally(next);
|
|
20
26
|
}
|
|
21
27
|
function processQueue() {
|
|
22
28
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.mjs","sources":["../../../src/view/queue.ts"],"sourcesContent":["import { removeItem } from \"motion-utils\"\nimport type { ViewTransitionBuilder } from \".\"\nimport { microtask } from \"../frameloop/microtask\"\nimport { startViewAnimation } from \"./start\"\n\nlet builders: ViewTransitionBuilder[] = []\n\nlet current: ViewTransitionBuilder | null = null\n\nfunction next() {\n current = null\n const [nextBuilder] = builders\n if (nextBuilder) start(nextBuilder)\n}\n\nfunction start(builder: ViewTransitionBuilder) {\n removeItem(builders, builder)\n current = builder\n startViewAnimation(builder).then((animation) => {\n
|
|
1
|
+
{"version":3,"file":"queue.mjs","sources":["../../../src/view/queue.ts"],"sourcesContent":["import { removeItem } from \"motion-utils\"\nimport type { ViewTransitionBuilder } from \".\"\nimport { microtask } from \"../frameloop/microtask\"\nimport { startViewAnimation } from \"./start\"\n\nlet builders: ViewTransitionBuilder[] = []\n\nlet current: ViewTransitionBuilder | null = null\n\nfunction next() {\n current = null\n const [nextBuilder] = builders\n if (nextBuilder) start(nextBuilder)\n}\n\nfunction start(builder: ViewTransitionBuilder) {\n removeItem(builders, builder)\n current = builder\n startViewAnimation(builder)\n .then((animation) => {\n builder.notifyReady(animation)\n return animation.finished\n })\n // A genuinely failed transition (a throwing update) rejects the\n // builder; a skipped/interrupted one resolves with no animations (see\n // start.ts). Either way, advance the queue - else later transitions hang.\n .catch((error) => builder.notifyReject(error))\n .finally(next)\n}\n\nfunction processQueue() {\n /**\n * Iterate backwards over the builders array. We can ignore the\n * \"wait\" animations. If we have an interrupting animation in the\n * queue then we need to batch all preceeding animations into it.\n * Currently this only batches the update functions but will also\n * need to batch the targets.\n */\n for (let i = builders.length - 1; i >= 0; i--) {\n const builder = builders[i]\n const { interrupt } = builder.options\n\n if (interrupt === \"immediate\") {\n const batchedUpdates = builders.slice(0, i + 1).map((b) => b.update)\n const remaining = builders.slice(i + 1)\n\n builder.update = () => {\n batchedUpdates.forEach((update) => update())\n }\n\n // Put the current builder at the front, followed by any \"wait\" builders\n builders = [builder, ...remaining]\n\n break\n }\n }\n\n if (!current || builders[0]?.options.interrupt === \"immediate\") {\n next()\n }\n}\n\nexport function addToQueue(builder: ViewTransitionBuilder) {\n builders.push(builder)\n microtask.render(processQueue)\n}\n"],"names":[],"mappings":";;;;AAKA,IAAI,QAAQ,GAA4B,EAAE;AAE1C,IAAI,OAAO,GAAiC,IAAI;AAEhD,SAAS,IAAI,GAAA;IACT,OAAO,GAAG,IAAI;AACd,IAAA,MAAM,CAAC,WAAW,CAAC,GAAG,QAAQ;AAC9B,IAAA,IAAI,WAAW;QAAE,KAAK,CAAC,WAAW,CAAC;AACvC;AAEA,SAAS,KAAK,CAAC,OAA8B,EAAA;AACzC,IAAA,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC7B,OAAO,GAAG,OAAO;IACjB,kBAAkB,CAAC,OAAO;AACrB,SAAA,IAAI,CAAC,CAAC,SAAS,KAAI;AAChB,QAAA,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC;QAC9B,OAAO,SAAS,CAAC,QAAQ;AAC7B,IAAA,CAAC;;;;AAIA,SAAA,KAAK,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;SAC5C,OAAO,CAAC,IAAI,CAAC;AACtB;AAEA,SAAS,YAAY,GAAA;AACjB;;;;;;AAMG;AACH,IAAA,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;AAC3C,QAAA,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC3B,QAAA,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,OAAO;AAErC,QAAA,I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