@astryxdesign/core 0.7.6-canary.554e9bc → 0.7.6-canary.5909b93
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/SideNav/railMotion.d.ts +5 -5
- package/dist/SideNav/railMotion.d.ts.map +1 -1
- package/dist/SideNav/railMotion.js +69 -177
- package/dist/motion/animatedLayout.d.ts +130 -5
- package/dist/motion/animatedLayout.d.ts.map +1 -1
- package/dist/motion/animatedLayout.js +771 -44
- package/package.json +4 -4
- package/src/SideNav/railMotion.ts +73 -179
- package/src/motion/animatedLayout.ts +977 -45
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AnimatedLayout, type LayoutSwap } from '../motion/animatedLayout.js';
|
|
1
|
+
import { type AnimatedLayout, type LayoutEdgeHold, type LayoutSwap } from '../motion/animatedLayout.js';
|
|
2
2
|
/** What AppShell lends its SideNav; outside AppShell, nothing. */
|
|
3
3
|
export interface SideNavShell {
|
|
4
4
|
/** AppShell's own handle, whose area holds the rail and the content. */
|
|
@@ -26,12 +26,12 @@ export interface RailShown {
|
|
|
26
26
|
readonly collapsed: number;
|
|
27
27
|
}
|
|
28
28
|
export interface RailSnapshot {
|
|
29
|
-
|
|
30
|
-
readonly
|
|
29
|
+
/** The old rail, held for the module's edge reveal. */
|
|
30
|
+
readonly hold: LayoutEdgeHold;
|
|
31
|
+
/** The old rail as one transient copy, or null when it cannot be held. */
|
|
32
|
+
readonly swap: LayoutSwap | null;
|
|
31
33
|
/** What the rail shows when the change lands. */
|
|
32
34
|
readonly shown: RailShown;
|
|
33
|
-
/** The old rail, held by the swap. */
|
|
34
|
-
readonly swap: LayoutSwap | null;
|
|
35
35
|
}
|
|
36
36
|
/** A playing rail motion. */
|
|
37
37
|
export interface RailMotion {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"railMotion.d.ts","sourceRoot":"","sources":["../../src/SideNav/railMotion.ts"],"names":[],"mappings":"
|
|
1
|
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AAI,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,SAAS,GAAG,IAAI,EACzB,WAAW,EAAE,OAAO,GACnB,YAAY,GAAG,IAAI,CAkBrB;AAaD;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,MAAM,EAAE,cAAc,EACtB,MAAM,GAAE,WAAW,GAAG,IAAW,GAChC,UAAU,CAmDZ"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file railMotion.ts
|
|
7
7
|
* @input The rail's outer element, the animated-layout module's handle,
|
|
8
|
-
* motion and
|
|
8
|
+
* motion and two-state edge reveal (motion/animatedLayout.ts)
|
|
9
9
|
* @output Exports `SideNavShellContext` (what AppShell lends its SideNav),
|
|
10
10
|
* `createRailLayout`, `snapshotRail` and `playRail`: the rail's collapse
|
|
11
11
|
* motion
|
|
@@ -14,34 +14,36 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Collapsing or expanding the rail plays one motion on one clock, the
|
|
16
16
|
* `springs.settle` role the animated-layout module reads (`spec:AST-105`
|
|
17
|
-
* FR4)
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
17
|
+
* FR4). The rail is FR9's edge reveal in its inline two-state form, which
|
|
18
|
+
* the module produces (`architecture:react-component-runtime` INV12): layout
|
|
19
|
+
* snaps to the final rail width at once, nothing animates a width, and the
|
|
20
|
+
* module clips the rail's inline-end edge from the width it shows to the new
|
|
21
|
+
* one. A collapse covers the old, expanded rail, held as one transient copy,
|
|
22
|
+
* with the real collapsed rail raised above it; an expand reveals the real
|
|
23
|
+
* rail under the old, collapsed one. In AppShell that edge rides the content
|
|
24
|
+
* column's glide, frame by frame, so the two never part, also when a change
|
|
25
|
+
* interrupts a running one. Every starting clip applies in the commit's
|
|
26
|
+
* layout effect, before the first frame paints. Under Reduce Motion it
|
|
27
|
+
* follows `design:reduced-motion`: opacity only under a coarse primary
|
|
28
|
+
* pointer (DR2), an immediate change otherwise (DR3). Without Web
|
|
29
|
+
* Animations, the change lands at once.
|
|
30
|
+
*
|
|
31
|
+
* What this file adds is the rail's own fades, on the same progress:
|
|
32
|
+
* - A collapse fades the copy's text over the first 40% and the copy over
|
|
33
|
+
* the last 30%, while the real collapsed rail, its icons, fades in over the
|
|
34
|
+
* last 30%, so the real rail, icons only, is all that remains.
|
|
35
|
+
* - An expand fades the real rail's text in over the last 60%, so no label
|
|
36
|
+
* shows at the collapsed width, while the old, collapsed rail fades over
|
|
37
|
+
* the first 60%: the first frame is the frame before the click.
|
|
31
38
|
* - A change made during a running motion starts from what the rail shows:
|
|
32
39
|
* its width, its labels' opacity and its collapsed icons' opacity, so the
|
|
33
40
|
* rail stays continuous.
|
|
34
|
-
* - Every starting clip applies in the commit's layout effect, before the
|
|
35
|
-
* first frame paints.
|
|
36
|
-
* - Under Reduce Motion it follows `design:reduced-motion`: opacity only
|
|
37
|
-
* under a coarse primary pointer (DR2), an immediate change otherwise
|
|
38
|
-
* (DR3). Without Web Animations, the change lands at once.
|
|
39
41
|
*
|
|
40
42
|
* SYNC: When modified, update SideNav.tsx, AppShell.tsx and
|
|
41
43
|
* SideNavRailMotion.test.tsx.
|
|
42
44
|
*/
|
|
43
45
|
import { createContext } from 'react';
|
|
44
|
-
import { createAnimatedLayout,
|
|
46
|
+
import { createAnimatedLayout, holdLayoutEdge, playLayoutEdge } from "../motion/animatedLayout.js";
|
|
45
47
|
|
|
46
48
|
/** What AppShell lends its SideNav; outside AppShell, nothing. */
|
|
47
49
|
|
|
@@ -62,19 +64,22 @@ export function createRailLayout(rail) {
|
|
|
62
64
|
* from a running motion or at rest.
|
|
63
65
|
*/
|
|
64
66
|
export function snapshotRail(rail, handle, running, isCollapsed) {
|
|
65
|
-
|
|
67
|
+
// The rail's edge is the one beside the content, its inline end.
|
|
68
|
+
const hold = holdLayoutEdge(handle, rail, {
|
|
69
|
+
edge: 'inline-end',
|
|
70
|
+
shown: running?.width ?? null
|
|
71
|
+
});
|
|
72
|
+
if (hold == null) {
|
|
66
73
|
return null;
|
|
67
74
|
}
|
|
68
|
-
const railRect = rail.getBoundingClientRect();
|
|
69
75
|
return {
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
hold,
|
|
77
|
+
swap: hold.swap,
|
|
72
78
|
shown: running ?? {
|
|
73
|
-
width:
|
|
79
|
+
width: hold.extent,
|
|
74
80
|
labels: isCollapsed ? 0 : 1,
|
|
75
81
|
collapsed: isCollapsed ? 1 : 0
|
|
76
|
-
}
|
|
77
|
-
swap: holdLayoutSwap(handle, rail)
|
|
82
|
+
}
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
const clamp = value => Math.min(1, Math.max(0, value));
|
|
@@ -84,19 +89,6 @@ function textElements(rail) {
|
|
|
84
89
|
return Array.from(rail.querySelectorAll('*')).filter(element => Array.from(element.childNodes).some(node => node.nodeType === 3 && node.textContent?.trim()));
|
|
85
90
|
}
|
|
86
91
|
|
|
87
|
-
/** `element`'s ancestor (or itself) that sits directly in `host`. */
|
|
88
|
-
function childOf(host, element) {
|
|
89
|
-
let node = element;
|
|
90
|
-
while (node != null && node.parentElement !== host) {
|
|
91
|
-
node = node.parentElement;
|
|
92
|
-
}
|
|
93
|
-
return node;
|
|
94
|
-
}
|
|
95
|
-
const AT_REST = {
|
|
96
|
-
end: () => {},
|
|
97
|
-
shown: () => null
|
|
98
|
-
};
|
|
99
|
-
|
|
100
92
|
/**
|
|
101
93
|
* After the change commits, before paint: play the rail's motion from the
|
|
102
94
|
* snapshot, on the module's motion. With a `column` (in AppShell), the rail's
|
|
@@ -104,150 +96,50 @@ const AT_REST = {
|
|
|
104
96
|
*/
|
|
105
97
|
export function playRail(snapshot, current, handle, column = null) {
|
|
106
98
|
const {
|
|
107
|
-
railRect,
|
|
108
|
-
swap,
|
|
109
99
|
shown: from
|
|
110
100
|
} = snapshot;
|
|
111
|
-
|
|
112
|
-
// wrapper comes and goes with the collapse.
|
|
113
|
-
const rail = current?.isConnected === true ? current : snapshot.rail;
|
|
114
|
-
if (!rail.isConnected) {
|
|
115
|
-
return AT_REST;
|
|
116
|
-
}
|
|
117
|
-
const motion = layoutMotionFor(rail);
|
|
118
|
-
const next = rail.getBoundingClientRect();
|
|
119
|
-
if (motion.kind === 'instant' || Math.abs(next.width - from.width) < 0.5) {
|
|
120
|
-
return AT_REST;
|
|
121
|
-
}
|
|
122
|
-
const isCollapse = next.width < from.width;
|
|
101
|
+
let isCollapse = false;
|
|
123
102
|
// The labels and the collapsed icons over the motion's progress, from what
|
|
124
103
|
// the rail showed.
|
|
125
104
|
const labelsAt = p => isCollapse ? from.labels * (1 - clamp(p / 0.4)) : from.labels + (1 - from.labels) * clamp((p - 0.4) / 0.6);
|
|
126
105
|
const collapsedAt = p => isCollapse ? from.collapsed + (1 - from.collapsed) * clamp((p - 0.7) / 0.3) : from.collapsed * (1 - clamp(p / 0.6));
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
106
|
+
const motion = playLayoutEdge(snapshot.hold, current, handle, {
|
|
107
|
+
edge: 'inline-end',
|
|
108
|
+
rideWith: column,
|
|
109
|
+
parts: (isConceal, rail) => {
|
|
110
|
+
isCollapse = isConceal;
|
|
111
|
+
return isConceal ? {
|
|
112
|
+
// The old rail's text fades early, the copy late, as the real
|
|
113
|
+
// collapsed rail, raised above it, fades in.
|
|
114
|
+
copyOpacity: p => 1 - clamp((p - 0.7) / 0.3),
|
|
115
|
+
copyText: labelsAt,
|
|
116
|
+
incoming: [{
|
|
117
|
+
element: rail,
|
|
118
|
+
frames: p => ({
|
|
119
|
+
opacity: collapsedAt(p)
|
|
120
|
+
})
|
|
121
|
+
}]
|
|
122
|
+
} : {
|
|
123
|
+
// The old, collapsed rail fades early; the real rail's text, late.
|
|
124
|
+
copyOpacity: collapsedAt,
|
|
125
|
+
incoming: textElements(rail).map(element => ({
|
|
126
|
+
element,
|
|
127
|
+
frames: p => ({
|
|
128
|
+
opacity: labelsAt(p)
|
|
129
|
+
})
|
|
130
|
+
}))
|
|
131
|
+
};
|
|
145
132
|
}
|
|
146
|
-
const p = motion.kind === 'spring' ? 1 - motion.progress.remaining(elapsed) : 0;
|
|
147
|
-
let width = from.width + (next.width - from.width) * p;
|
|
148
|
-
if (rides && column != null) {
|
|
149
|
-
// The rail's edge is the column's: read it where it shows.
|
|
150
|
-
const edge = column.getBoundingClientRect();
|
|
151
|
-
const own = rail.getBoundingClientRect();
|
|
152
|
-
width = rtl ? own.right - edge.right : edge.left - own.left;
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
width,
|
|
156
|
-
labels: labelsAt(p),
|
|
157
|
-
collapsed: collapsedAt(p)
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
const rideWith = rides && column != null ? {
|
|
161
|
-
element: column,
|
|
162
|
-
travel: {
|
|
163
|
-
x: sign * (from.width - next.width),
|
|
164
|
-
y: 0
|
|
165
|
-
},
|
|
166
|
-
isCopyMoved: false
|
|
167
|
-
} : undefined;
|
|
168
|
-
// The copy keeps the rail's inline-start edge where the rail is now, so it
|
|
169
|
-
// meets the real rail wherever SideNav sits (a centered rail moves).
|
|
170
|
-
const at = DOMRect.fromRect({
|
|
171
|
-
x: rtl ? next.right - railRect.width : next.left,
|
|
172
|
-
y: next.top,
|
|
173
|
-
width: railRect.width,
|
|
174
|
-
height: railRect.height
|
|
175
133
|
});
|
|
176
|
-
if (isCollapse) {
|
|
177
|
-
// A collapse covers the old rail, held by the swap, from the width it
|
|
178
|
-
// shows down to the new one; the real, collapsed rail fades in above it.
|
|
179
|
-
if (swap == null || host == null) {
|
|
180
|
-
return AT_REST;
|
|
181
|
-
}
|
|
182
|
-
const raised = childOf(host, rail);
|
|
183
|
-
const restore = raised == null ? null : {
|
|
184
|
-
position: raised.style.position,
|
|
185
|
-
zIndex: raised.style.zIndex
|
|
186
|
-
};
|
|
187
|
-
if (raised != null) {
|
|
188
|
-
if (getComputedStyle(raised).position === 'static') {
|
|
189
|
-
raised.style.position = 'relative';
|
|
190
|
-
}
|
|
191
|
-
raised.style.zIndex = '2';
|
|
192
|
-
}
|
|
193
|
-
const end = playLayoutSwap({
|
|
194
|
-
...swap,
|
|
195
|
-
rect: at
|
|
196
|
-
}, {
|
|
197
|
-
host,
|
|
198
|
-
isOpaque: true,
|
|
199
|
-
copy: (p, ride) => ({
|
|
200
|
-
clipPath: inset(railRect.width - widthAt(p, ride)),
|
|
201
|
-
opacity: 1 - clamp((p - 0.7) / 0.3)
|
|
202
|
-
}),
|
|
203
|
-
copyText: labelsAt,
|
|
204
|
-
rideWith,
|
|
205
|
-
onEnd: () => {
|
|
206
|
-
if (raised != null && restore != null) {
|
|
207
|
-
raised.style.position = restore.position;
|
|
208
|
-
raised.style.zIndex = restore.zIndex;
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
incoming: [{
|
|
212
|
-
element: rail,
|
|
213
|
-
frames: p => ({
|
|
214
|
-
opacity: collapsedAt(p)
|
|
215
|
-
})
|
|
216
|
-
}]
|
|
217
|
-
});
|
|
218
|
-
return {
|
|
219
|
-
end,
|
|
220
|
-
shown
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// An expand reveals the real rail from the width it showed, its text fading
|
|
225
|
-
// in late, under the old, collapsed rail fading early.
|
|
226
|
-
const incoming = [{
|
|
227
|
-
element: rail,
|
|
228
|
-
frames: (p, ride) => ({
|
|
229
|
-
clipPath: inset(next.width - widthAt(p, ride))
|
|
230
|
-
})
|
|
231
|
-
}, ...textElements(rail).map(element => ({
|
|
232
|
-
element,
|
|
233
|
-
frames: p => ({
|
|
234
|
-
opacity: labelsAt(p)
|
|
235
|
-
})
|
|
236
|
-
}))];
|
|
237
|
-
const end = swap != null && host != null ? playLayoutSwap({
|
|
238
|
-
...swap,
|
|
239
|
-
rect: at
|
|
240
|
-
}, {
|
|
241
|
-
host,
|
|
242
|
-
isOpaque: true,
|
|
243
|
-
copy: p => ({
|
|
244
|
-
opacity: collapsedAt(p)
|
|
245
|
-
}),
|
|
246
|
-
rideWith,
|
|
247
|
-
incoming
|
|
248
|
-
}) : playLayoutFrames(handle, incoming);
|
|
249
134
|
return {
|
|
250
|
-
end,
|
|
251
|
-
shown
|
|
135
|
+
end: motion.end,
|
|
136
|
+
shown: () => {
|
|
137
|
+
const now = motion.shown();
|
|
138
|
+
return now == null ? null : {
|
|
139
|
+
width: now.extent,
|
|
140
|
+
labels: labelsAt(now.progress),
|
|
141
|
+
collapsed: collapsedAt(now.progress)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
252
144
|
};
|
|
253
145
|
}
|
|
@@ -58,13 +58,26 @@ export interface LayoutChange {
|
|
|
58
58
|
* outside its container, nothing moves.
|
|
59
59
|
*/
|
|
60
60
|
export declare function reportLayoutChange(handle: AnimatedLayout | null | undefined, target: Target): LayoutChange;
|
|
61
|
+
/**
|
|
62
|
+
* The edge an element reveals from or conceals to (`spec:AST-105` FR9): its
|
|
63
|
+
* block-end edge by default, or its block-start, inline-start or inline-end
|
|
64
|
+
* edge, such as a panel collapsing beside content. An inline edge follows
|
|
65
|
+
* the element's direction.
|
|
66
|
+
*/
|
|
67
|
+
export type LayoutEdge = 'block-end' | 'block-start' | 'inline-start' | 'inline-end';
|
|
61
68
|
/**
|
|
62
69
|
* The changed element's own animation, on the same motion as the content
|
|
63
|
-
* after it: content that appears reveals
|
|
64
|
-
*
|
|
65
|
-
*
|
|
70
|
+
* after it (`spec:AST-105` FR4): content that appears reveals from its
|
|
71
|
+
* block-end edge downward, or from the `edge` it is given (FR9), and its edge
|
|
72
|
+
* rides the glide of the content on that side once it starts. A reveal that
|
|
73
|
+
* reverses a running conceal (an adopter opens it again mid-exit, after
|
|
74
|
+
* `releaseLayoutExit`) starts from what the element shows. Plays only with a
|
|
75
|
+
* handle, inside its area and in the area's visible part. Returns the
|
|
76
|
+
* entrance it started, or null when it played none.
|
|
66
77
|
*/
|
|
67
|
-
export declare function playLayoutChange(handle: AnimatedLayout | null | undefined, element: Element
|
|
78
|
+
export declare function playLayoutChange(handle: AnimatedLayout | null | undefined, element: Element, { edge }?: {
|
|
79
|
+
edge?: LayoutEdge;
|
|
80
|
+
}): Animation | null;
|
|
68
81
|
/**
|
|
69
82
|
* The changed element's exit (`spec:AST-105` FR4): content that disappears
|
|
70
83
|
* keeps its place on screen but gives up its space (a negative end margin
|
|
@@ -77,6 +90,11 @@ export declare function playLayoutChange(handle: AnimatedLayout | null | undefin
|
|
|
77
90
|
* element, after the change's `animate()` reported it measured, in the same
|
|
78
91
|
* task: the glide reads the layout once the element has given up its space.
|
|
79
92
|
*
|
|
93
|
+
* It conceals to its block-end edge by default, or to the `edge` it is given
|
|
94
|
+
* (`spec:AST-105` FR9), and its edge rides the glide of the content on that
|
|
95
|
+
* side once it starts; a conceal that reverses a running reveal (a close
|
|
96
|
+
* while it opens) starts from what the element shows.
|
|
97
|
+
*
|
|
80
98
|
* Returns false, holding nothing, when the exit lands at once: no handle, a
|
|
81
99
|
* close no change in the area measured, outside the area or its visible part,
|
|
82
100
|
* Reduce Motion with a fine pointer, or a layout no end margin can free (a
|
|
@@ -84,7 +102,9 @@ export declare function playLayoutChange(handle: AnimatedLayout | null | undefin
|
|
|
84
102
|
* that last case the content after it takes its final place at once too.
|
|
85
103
|
* The component then hides the element itself.
|
|
86
104
|
*/
|
|
87
|
-
export declare function holdLayoutExit(handle: AnimatedLayout | null | undefined, element: HTMLElement, done: () => void
|
|
105
|
+
export declare function holdLayoutExit(handle: AnimatedLayout | null | undefined, element: HTMLElement, done: () => void, { edge }?: {
|
|
106
|
+
edge?: LayoutEdge;
|
|
107
|
+
}): boolean;
|
|
88
108
|
/**
|
|
89
109
|
* Puts an element `holdLayoutExit` held back: stops its exit and puts back
|
|
90
110
|
* what the exit replaced (its `inert` and inline values as they were). Called
|
|
@@ -167,6 +187,111 @@ export declare function playLayoutSwap(swap: LayoutSwap, how: LayoutSwapMotion):
|
|
|
167
187
|
* nothing plays. Returns what ends them at once.
|
|
168
188
|
*/
|
|
169
189
|
export declare function playLayoutFrames(handle: AnimatedLayout | null | undefined, parts: LayoutSwapMotion['incoming']): () => void;
|
|
190
|
+
/**
|
|
191
|
+
* An element's old state, held before a change commits for FR9's two-state
|
|
192
|
+
* edge reveal.
|
|
193
|
+
*/
|
|
194
|
+
export interface LayoutEdgeHold {
|
|
195
|
+
readonly element: HTMLElement;
|
|
196
|
+
/** Where it showed, in viewport coordinates. */
|
|
197
|
+
readonly rect: DOMRect;
|
|
198
|
+
/**
|
|
199
|
+
* Its size along the edge's axis as it shows: what a running reveal shows
|
|
200
|
+
* mid-motion, or its box.
|
|
201
|
+
*/
|
|
202
|
+
readonly extent: number;
|
|
203
|
+
/** Its old state as one transient copy, or null when it cannot be held. */
|
|
204
|
+
readonly swap: LayoutSwap | null;
|
|
205
|
+
}
|
|
206
|
+
/** A playing two-state edge reveal. */
|
|
207
|
+
export interface LayoutEdgeMotion {
|
|
208
|
+
/** Ends it at once (a new change, an unmount). */
|
|
209
|
+
end(): void;
|
|
210
|
+
/**
|
|
211
|
+
* What it shows now: its extent along the edge's axis and the motion's
|
|
212
|
+
* progress (0 → 1), or null once it has settled.
|
|
213
|
+
*/
|
|
214
|
+
shown(): {
|
|
215
|
+
readonly extent: number;
|
|
216
|
+
readonly progress: number;
|
|
217
|
+
} | null;
|
|
218
|
+
}
|
|
219
|
+
/** What the caller adds to a two-state edge reveal: only its own fades. */
|
|
220
|
+
export interface LayoutEdgeParts {
|
|
221
|
+
/** The old state's copy's opacity over the progress (1 when absent). */
|
|
222
|
+
readonly copyOpacity?: (p: number) => number;
|
|
223
|
+
/** Its text's opacity, on its own curve, when that differs from the copy's. */
|
|
224
|
+
readonly copyText?: (p: number) => number;
|
|
225
|
+
/** Parts the page renders, playing with the reveal (the new state's text). */
|
|
226
|
+
readonly incoming?: ReadonlyArray<{
|
|
227
|
+
readonly element: Element;
|
|
228
|
+
readonly frames: (p: number) => Keyframe;
|
|
229
|
+
}>;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Before a change commits: hold `element`'s old state for FR9's two-state edge
|
|
233
|
+
* reveal, its box and the extent it shows along `edge`'s axis (`shown`, from a
|
|
234
|
+
* running reveal, or its box), and its old state as one transient copy (null
|
|
235
|
+
* when it cannot be copied, or under an immediate change). Returns null
|
|
236
|
+
* without the element or without Web Animations.
|
|
237
|
+
*/
|
|
238
|
+
export declare function holdLayoutEdge(handle: AnimatedLayout | null | undefined, element: HTMLElement | null, { edge, shown, }?: {
|
|
239
|
+
edge?: LayoutEdge;
|
|
240
|
+
shown?: number | null;
|
|
241
|
+
}): LayoutEdgeHold | null;
|
|
242
|
+
/**
|
|
243
|
+
* After the change commits, before paint: FR9's two-state edge reveal, on
|
|
244
|
+
* FR4's one motion. The state that is larger along `edge`'s axis is clipped
|
|
245
|
+
* on that edge, from the extent the element showed to the new one: a conceal
|
|
246
|
+
* covers the old state, held as the swap's copy, with the element raised
|
|
247
|
+
* above it; a reveal opens the element, under the old state. With
|
|
248
|
+
* `rideWith`, an element the glide moves after that edge (a rail's content
|
|
249
|
+
* column), the edge rides its glide, frame by frame, so the two never part,
|
|
250
|
+
* also when this reverses a running reveal; without it the edge follows the
|
|
251
|
+
* motion's curve. `parts` gives the caller's own fades, told whether the edge
|
|
252
|
+
* conceals and the element as it is now. Under Reduce Motion it follows
|
|
253
|
+
* `design:reduced-motion`: opacity only under a coarse primary pointer (DR2),
|
|
254
|
+
* an immediate change otherwise (DR3). `current` is the element after the
|
|
255
|
+
* commit, when it remounted.
|
|
256
|
+
*/
|
|
257
|
+
export declare function playLayoutEdge(hold: LayoutEdgeHold, current: HTMLElement | null, handle: AnimatedLayout, { edge, rideWith, parts, }?: {
|
|
258
|
+
edge?: LayoutEdge;
|
|
259
|
+
rideWith?: Element | null;
|
|
260
|
+
parts?: (isConceal: boolean, element: HTMLElement) => LayoutEdgeParts;
|
|
261
|
+
}): LayoutEdgeMotion;
|
|
262
|
+
/** A resized element's edge reveal, reported around its change. */
|
|
263
|
+
export interface LayoutEdgeReport {
|
|
264
|
+
/** Before the change commits: measures the element and what moves. */
|
|
265
|
+
measureBefore(): void;
|
|
266
|
+
/**
|
|
267
|
+
* After the new size is applied, before paint: the element reveals or
|
|
268
|
+
* conceals by its edge, from the extent it showed to its new one, and the
|
|
269
|
+
* content beside it glides on the same motion.
|
|
270
|
+
*/
|
|
271
|
+
animate(): void;
|
|
272
|
+
/** Ends a running reveal or conceal at once, removing what it holds. */
|
|
273
|
+
cancel(): void;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Reports a resized element's edge reveal (`spec:AST-105` FR9) with no copy:
|
|
277
|
+
* a resize controller's pane collapsing or opening beside the content it
|
|
278
|
+
* shares a row with (`component:Resizable` FR8, `component:LayoutPanel`
|
|
279
|
+
* FR7). Measure before the change commits and animate after the
|
|
280
|
+
* new size is applied, as `reportLayoutChange` does; the content beside the
|
|
281
|
+
* element glides through that report. A larger extent reveals by `edge` from
|
|
282
|
+
* the extent the element showed. A smaller one conceals: the element is held
|
|
283
|
+
* at the extent it was laid out at, the difference freed by the margin on
|
|
284
|
+
* that edge's side so the content beyond it stays where the new size puts it,
|
|
285
|
+
* and clipped down to its new extent; the hold goes when the motion ends. The
|
|
286
|
+
* moving edge rides the glide of the content on that side, frame by frame,
|
|
287
|
+
* and a change made while it runs starts from the extent it shows. It slides:
|
|
288
|
+
* nothing fades. Under Reduce Motion with a coarse primary pointer a reveal
|
|
289
|
+
* fades in and a conceal lands at once (`design:reduced-motion` DR2); with a
|
|
290
|
+
* fine one every change lands at once (DR3).
|
|
291
|
+
*/
|
|
292
|
+
export declare function reportLayoutEdge(handle: AnimatedLayout | null | undefined, getElement: () => HTMLElement | null, { edge }?: {
|
|
293
|
+
edge?: LayoutEdge;
|
|
294
|
+
}): LayoutEdgeReport;
|
|
170
295
|
/**
|
|
171
296
|
* A disclosure's indicator (its chevron) turns on the same motion as the
|
|
172
297
|
* glide: its CSS transition takes the spring as a `linear()` easing, and an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animatedLayout.d.ts","sourceRoot":"","sources":["../../src/motion/animatedLayout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"animatedLayout.d.ts","sourceRoot":"","sources":["../../src/motion/animatedLayout.ts"],"names":[],"mappings":"AAsGA,sDAAsD;AACtD,KAAK,YAAY,GACb;IAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAAC,GAC5D;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAC,CAAC;AAE/B,yEAAyE;AACzE,UAAU,cAAc;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAgQD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAE1D;AAMD,QAAA,MAAM,IAA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