@fusion.dev/helix-core 0.241.3 → 0.242.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/custom-elements.json +1 -1
- package/dist/controllers/count-controller/count-controller.d.ts +52 -0
- package/dist/controllers/count-controller/count-controller.js +61 -0
- package/dist/controllers/hover-mark-controller/hover-mark-controller.d.ts +51 -0
- package/dist/controllers/hover-mark-controller/hover-mark-controller.js +64 -0
- package/dist/controllers/indicator-controller/indicator-controller.d.ts +10 -0
- package/dist/controllers/indicator-controller/indicator-controller.js +31 -0
- package/dist/controllers/layout-motion-controller/layout-motion-controller.d.ts +186 -0
- package/dist/controllers/layout-motion-controller/layout-motion-controller.js +284 -0
- package/dist/controllers/pointer-follow-controller/pointer-follow-controller.d.ts +41 -0
- package/dist/controllers/pointer-follow-controller/pointer-follow-controller.js +59 -0
- package/dist/helix-element/mark-rules.d.ts +19 -0
- package/dist/helix-element/mark-rules.js +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +8 -1
- package/dist/utils/arrive/arrive.d.ts +21 -0
- package/dist/utils/arrive/arrive.js +22 -0
- package/dist/utils/color-mode/color-mode.d.ts +60 -0
- package/dist/utils/color-mode/color-mode.js +95 -0
- package/dist/utils/page-transition/page-transition.d.ts +45 -0
- package/dist/utils/page-transition/page-transition.js +36 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
/** What a `CountController` reads of its host. */
|
|
3
|
+
export interface CountOptions {
|
|
4
|
+
/**
|
|
5
|
+
* How long a count takes and its curve, as the host's family hooks hold
|
|
6
|
+
* them, such as `--stat-count-duration` and `--stat-count-easing`. Read when
|
|
7
|
+
* a count starts. A duration that is empty, or under a millisecond, counts
|
|
8
|
+
* nothing.
|
|
9
|
+
*/
|
|
10
|
+
timing: () => {
|
|
11
|
+
duration: string;
|
|
12
|
+
easing: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Counts a figure from the number it showed to a new one, once a frame, so a
|
|
17
|
+
* figure that a dashboard refreshes reads as having moved. Serves `Stat` and
|
|
18
|
+
* `Trend`.
|
|
19
|
+
*
|
|
20
|
+
* **The browser runs the curve.** An animation with no keyframes changes
|
|
21
|
+
* nothing on screen, and its eased progress is the share of the way the figure
|
|
22
|
+
* has come, so `linear()` and `cubic-bezier()` count exactly as a transition
|
|
23
|
+
* with the same curve moves. Each figure is rounded to as many decimals as the
|
|
24
|
+
* two numbers have, so a count to 1,284 shows no fractions.
|
|
25
|
+
*
|
|
26
|
+
* **The stylesheet decides whether anything counts**, through the timing the
|
|
27
|
+
* host's family hooks hold, which the styled tier sets from the tokens. The
|
|
28
|
+
* headless tier sets none, so a new figure shows at once there, and so it does
|
|
29
|
+
* under reduced motion, whatever the hooks say.
|
|
30
|
+
*
|
|
31
|
+
* The host draws `counting` while it is a number, and asks for an update on
|
|
32
|
+
* every frame through `requestUpdate`. A count interrupted by another starts
|
|
33
|
+
* from the figure drawn.
|
|
34
|
+
*/
|
|
35
|
+
export declare class CountController implements ReactiveController {
|
|
36
|
+
private readonly host;
|
|
37
|
+
private readonly options;
|
|
38
|
+
/** The figure to draw while a count runs, or `undefined` at rest. */
|
|
39
|
+
counting: number | undefined;
|
|
40
|
+
/** The count in flight. */
|
|
41
|
+
private clock;
|
|
42
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: CountOptions);
|
|
43
|
+
hostDisconnected(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Counts from `from`, or from the figure drawn where a count is running, to
|
|
46
|
+
* `to`. Does nothing where the two are the same, either is no number, or the
|
|
47
|
+
* timing or the reader's setting says not to move.
|
|
48
|
+
*/
|
|
49
|
+
start(from: number, to: number | undefined): void;
|
|
50
|
+
/** Ends a count where it is, leaving the host to draw its own figure. */
|
|
51
|
+
private stop;
|
|
52
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { reducedMotion } from '../../utils/page-motion/page-motion.js';
|
|
2
|
+
const milliseconds = (value) => {
|
|
3
|
+
const amount = Number.parseFloat(value);
|
|
4
|
+
if (!Number.isFinite(amount)) {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
return value.trim().endsWith('ms') ? amount : amount * 1000;
|
|
8
|
+
};
|
|
9
|
+
const decimals = (value) => {
|
|
10
|
+
const written = String(value);
|
|
11
|
+
const point = written.indexOf('.');
|
|
12
|
+
return point === -1 || written.includes('e') ? 0 : written.length - point - 1;
|
|
13
|
+
};
|
|
14
|
+
export class CountController {
|
|
15
|
+
constructor(host, options) {
|
|
16
|
+
this.host = host;
|
|
17
|
+
this.options = options;
|
|
18
|
+
host.addController(this);
|
|
19
|
+
}
|
|
20
|
+
hostDisconnected() {
|
|
21
|
+
this.stop();
|
|
22
|
+
}
|
|
23
|
+
start(from, to) {
|
|
24
|
+
const begin = this.counting ?? from;
|
|
25
|
+
this.stop();
|
|
26
|
+
if (to === undefined || !Number.isFinite(to) || !Number.isFinite(begin) || begin === to) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const timing = this.options.timing();
|
|
30
|
+
const duration = milliseconds(timing.duration);
|
|
31
|
+
if (duration < 1 || reducedMotion() || typeof this.host.animate !== 'function') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const easing = timing.easing.trim() || 'ease';
|
|
35
|
+
const places = 10 ** Math.max(decimals(begin), decimals(to));
|
|
36
|
+
const clock = this.host.animate([], { duration, easing });
|
|
37
|
+
this.clock = clock;
|
|
38
|
+
this.counting = begin;
|
|
39
|
+
const frame = () => {
|
|
40
|
+
if (this.clock !== clock) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const progress = clock.effect?.getComputedTiming().progress;
|
|
44
|
+
if (clock.playState === 'finished' || typeof progress !== 'number') {
|
|
45
|
+
this.clock = undefined;
|
|
46
|
+
this.counting = undefined;
|
|
47
|
+
this.host.requestUpdate();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.counting = Math.round((begin + (to - begin) * progress) * places) / places;
|
|
51
|
+
this.host.requestUpdate();
|
|
52
|
+
requestAnimationFrame(frame);
|
|
53
|
+
};
|
|
54
|
+
requestAnimationFrame(frame);
|
|
55
|
+
}
|
|
56
|
+
stop() {
|
|
57
|
+
this.clock?.cancel();
|
|
58
|
+
this.clock = undefined;
|
|
59
|
+
this.counting = undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
/** What a `HoverMarkController` needs of its host. */
|
|
3
|
+
export interface HoverMarkOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Told when the mark arrives over the items and when it leaves them, so the
|
|
6
|
+
* host can hold `:state(gliding)` for its stylesheet.
|
|
7
|
+
*/
|
|
8
|
+
gliding: (on: boolean) => void;
|
|
9
|
+
/** The item a pointer is over, from what is under it, or nothing where it is between items. */
|
|
10
|
+
item: (under: readonly EventTarget[]) => HTMLElement | undefined;
|
|
11
|
+
/** The mark that travels to the item under the pointer. */
|
|
12
|
+
mark: () => HTMLElement | null | undefined;
|
|
13
|
+
/** Elements whose size moves the mark, beyond the host, as `IndicatorController` takes them. */
|
|
14
|
+
observe?: () => readonly Element[];
|
|
15
|
+
/** The box the mark is positioned against, as `IndicatorController` takes it. */
|
|
16
|
+
surface: () => HTMLElement | null | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Moves one mark to whichever item a mouse or pen is over, so the wash under
|
|
20
|
+
* the pointer glides from item to item instead of going out on one and coming
|
|
21
|
+
* on at the next. Serves `Navigation` and `Tabs`.
|
|
22
|
+
*
|
|
23
|
+
* **Placed by `IndicatorController`**, so the mark carries the same four
|
|
24
|
+
* properties a selection mark does, `--indicator-x`, `--indicator-y`,
|
|
25
|
+
* `--indicator-inline-size` and `--indicator-block-size`, signed in a
|
|
26
|
+
* right-to-left document and in layout pixels under a transform, and
|
|
27
|
+
* `data-placed` while it is over an item.
|
|
28
|
+
*
|
|
29
|
+
* **It glides only between items.** Arriving from outside, it is placed where
|
|
30
|
+
* the pointer is and fades in, and `data-gliding` comes a frame later, so a
|
|
31
|
+
* stylesheet that moves the mark only under `data-gliding` never slides it in
|
|
32
|
+
* from where it was last. `gliding` hears the arrival and the departure, so
|
|
33
|
+
* the host can hold `:state(gliding)` between them, which a stylesheet reads
|
|
34
|
+
* to take each item's own hover wash away while the mark draws it.
|
|
35
|
+
*
|
|
36
|
+
* **A touch is not followed**, since a finger leaves no hover to draw.
|
|
37
|
+
*/
|
|
38
|
+
export declare class HoverMarkController implements ReactiveController {
|
|
39
|
+
private readonly host;
|
|
40
|
+
private readonly options;
|
|
41
|
+
/** The item the mark is over. */
|
|
42
|
+
hovered: HTMLElement | undefined;
|
|
43
|
+
/** The frame that lets the mark glide, after its first placement. */
|
|
44
|
+
private frame;
|
|
45
|
+
private readonly placer;
|
|
46
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: HoverMarkOptions);
|
|
47
|
+
hostConnected(): void;
|
|
48
|
+
hostDisconnected(): void;
|
|
49
|
+
private readonly over;
|
|
50
|
+
private readonly leave;
|
|
51
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { IndicatorController } from '../indicator-controller/indicator-controller.js';
|
|
2
|
+
export class HoverMarkController {
|
|
3
|
+
constructor(host, options) {
|
|
4
|
+
this.frame = 0;
|
|
5
|
+
this.over = (event) => {
|
|
6
|
+
if (event.pointerType === 'touch') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const under = event.composedPath();
|
|
10
|
+
const item = this.options.item(under);
|
|
11
|
+
if (item === this.hovered) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (!item) {
|
|
15
|
+
const surface = this.options.surface();
|
|
16
|
+
if (!surface || !under.includes(surface)) {
|
|
17
|
+
this.leave();
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const arriving = this.hovered === undefined;
|
|
22
|
+
this.hovered = item;
|
|
23
|
+
this.placer.place();
|
|
24
|
+
if (!arriving) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.options.gliding(true);
|
|
28
|
+
cancelAnimationFrame(this.frame);
|
|
29
|
+
this.frame = requestAnimationFrame(() => {
|
|
30
|
+
this.frame = 0;
|
|
31
|
+
this.options.mark()?.toggleAttribute('data-gliding', this.hovered !== undefined);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
this.leave = () => {
|
|
35
|
+
cancelAnimationFrame(this.frame);
|
|
36
|
+
this.frame = 0;
|
|
37
|
+
if (this.hovered === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.hovered = undefined;
|
|
41
|
+
this.placer.place();
|
|
42
|
+
this.options.mark()?.removeAttribute('data-gliding');
|
|
43
|
+
this.options.gliding(false);
|
|
44
|
+
};
|
|
45
|
+
this.host = host;
|
|
46
|
+
this.options = options;
|
|
47
|
+
this.placer = new IndicatorController(host, {
|
|
48
|
+
active: () => this.hovered,
|
|
49
|
+
indicator: options.mark,
|
|
50
|
+
...(options.observe ? { observe: options.observe } : {}),
|
|
51
|
+
surface: options.surface,
|
|
52
|
+
});
|
|
53
|
+
host.addController(this);
|
|
54
|
+
}
|
|
55
|
+
hostConnected() {
|
|
56
|
+
this.host.addEventListener('pointerover', this.over);
|
|
57
|
+
this.host.addEventListener('pointerleave', this.leave);
|
|
58
|
+
}
|
|
59
|
+
hostDisconnected() {
|
|
60
|
+
this.host.removeEventListener('pointerover', this.over);
|
|
61
|
+
this.host.removeEventListener('pointerleave', this.leave);
|
|
62
|
+
this.leave();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -94,6 +94,16 @@ export declare class IndicatorController implements ReactiveController {
|
|
|
94
94
|
hostDisconnected(): void;
|
|
95
95
|
/** Called after every update, which is when the marked child may have moved. */
|
|
96
96
|
hostUpdated(): void;
|
|
97
|
+
/** Whether a placement is waiting for the marked item's move to end. */
|
|
98
|
+
private held;
|
|
99
|
+
/**
|
|
100
|
+
* **The moves the marked item is in**, its own and those of the boxes
|
|
101
|
+
* around it: finite animations of `transform`, `translate` or `scale`, such
|
|
102
|
+
* as a row sliding to its new place or an item settling as it arrives. Its
|
|
103
|
+
* box is wherever the move has it, so a mark measured then lands off its
|
|
104
|
+
* item and stays there, nothing moving the item again to place it anew.
|
|
105
|
+
*/
|
|
106
|
+
private movesOf;
|
|
97
107
|
/** Where the mark was last put, so a placement can tell a move from a resize. */
|
|
98
108
|
private last;
|
|
99
109
|
/** The guard behind `transitionend`, in case it never comes. */
|
|
@@ -5,6 +5,7 @@ const scaleOf = (surface, own) => {
|
|
|
5
5
|
};
|
|
6
6
|
export class IndicatorController {
|
|
7
7
|
constructor(host, options) {
|
|
8
|
+
this.held = false;
|
|
8
9
|
this.host = host;
|
|
9
10
|
this.options = options;
|
|
10
11
|
host.addController(this);
|
|
@@ -27,6 +28,25 @@ export class IndicatorController {
|
|
|
27
28
|
hostUpdated() {
|
|
28
29
|
this.place();
|
|
29
30
|
}
|
|
31
|
+
movesOf(active) {
|
|
32
|
+
const moves = [];
|
|
33
|
+
for (let up = active; up; up = up.parentElement) {
|
|
34
|
+
for (const one of up.getAnimations?.() ?? []) {
|
|
35
|
+
const effect = one.effect;
|
|
36
|
+
const end = effect?.getComputedTiming().endTime;
|
|
37
|
+
const moving = effect
|
|
38
|
+
?.getKeyframes()
|
|
39
|
+
.some((frame) => 'transform' in frame || 'translate' in frame || 'scale' in frame);
|
|
40
|
+
if (one.playState === 'running' &&
|
|
41
|
+
moving &&
|
|
42
|
+
typeof end === 'number' &&
|
|
43
|
+
Number.isFinite(end)) {
|
|
44
|
+
moves.push(one);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return moves;
|
|
49
|
+
}
|
|
30
50
|
place() {
|
|
31
51
|
this.watch();
|
|
32
52
|
const indicator = this.options.indicator();
|
|
@@ -39,6 +59,17 @@ export class IndicatorController {
|
|
|
39
59
|
indicator.removeAttribute('data-placed');
|
|
40
60
|
return;
|
|
41
61
|
}
|
|
62
|
+
const moves = this.movesOf(active);
|
|
63
|
+
if (moves.length > 0) {
|
|
64
|
+
if (!this.held) {
|
|
65
|
+
this.held = true;
|
|
66
|
+
void Promise.all(moves.map((one) => one.finished.catch(() => undefined))).then(() => {
|
|
67
|
+
this.held = false;
|
|
68
|
+
this.place();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
42
73
|
const box = this.span(active);
|
|
43
74
|
const own = surface.getBoundingClientRect();
|
|
44
75
|
if (box.width === 0 && box.height === 0) {
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
/** What a `LayoutMotionController` reads of its host. */
|
|
3
|
+
export interface LayoutMotionOptions {
|
|
4
|
+
/** Every item that can move, in the order they are drawn. Read at every change. */
|
|
5
|
+
items: () => readonly HTMLElement[];
|
|
6
|
+
/**
|
|
7
|
+
* How long a move takes and its curve, as the host's family hooks hold them,
|
|
8
|
+
* such as `--list-move-duration` and `--list-move-easing`. Read at every
|
|
9
|
+
* change. A duration that is empty, or under a millisecond, moves nothing.
|
|
10
|
+
*/
|
|
11
|
+
timing: () => {
|
|
12
|
+
duration: string;
|
|
13
|
+
easing: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* What says the items changed. `children`, the default, hears the page add,
|
|
17
|
+
* remove, reorder or hide the host's children. `updates` looks once each
|
|
18
|
+
* update of the host has finished, for a host that draws or arranges its
|
|
19
|
+
* items itself: a table that sorts by assigning its rows to a slot in a new
|
|
20
|
+
* order, or one that renders its rows.
|
|
21
|
+
*/
|
|
22
|
+
watch?: 'children' | 'updates';
|
|
23
|
+
/**
|
|
24
|
+
* The box the items scroll in, where it is not the page: a table that
|
|
25
|
+
* scrolls sideways in its own box. Its scroll is added back to each place,
|
|
26
|
+
* so a reader who scrolled between two changes does not see every row slide
|
|
27
|
+
* by the distance they scrolled.
|
|
28
|
+
*/
|
|
29
|
+
scroller?: () => Element | null | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* The boxes an item is drawn in, where they are not the item and what it
|
|
32
|
+
* draws: a table's column is its heading and the cells under it, which
|
|
33
|
+
* live in different rows. The first is the one its place is measured by,
|
|
34
|
+
* and each is resolved as an item is, so one that is `display: contents`
|
|
35
|
+
* gives the boxes it draws.
|
|
36
|
+
*/
|
|
37
|
+
boxes?: (item: HTMLElement) => readonly HTMLElement[];
|
|
38
|
+
/**
|
|
39
|
+
* Where a copy of an item that leaves is laid while it fades, for a list
|
|
40
|
+
* whose items go one at a time, such as a field's tags or a feed's rows:
|
|
41
|
+
* a positioned box in the host's shadow root, or the shadow root itself
|
|
42
|
+
* for a host that is positioned. Where it is not given, an item that
|
|
43
|
+
* leaves is simply gone, and the items after it slide into its room.
|
|
44
|
+
*/
|
|
45
|
+
leaving?: () => HTMLElement | ShadowRoot | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the first items into a list that was empty fade in. Off, they
|
|
48
|
+
* are a list arriving whole, which stands still, as a table's first page
|
|
49
|
+
* does. On for a field whose first tag or file the reader just chose.
|
|
50
|
+
*/
|
|
51
|
+
arriveIntoEmpty?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Moves each item from where it was drawn to where it is drawn after a change,
|
|
55
|
+
* so a row that is added, sorted, hidden or closed up slides into its place
|
|
56
|
+
* instead of jumping there.
|
|
57
|
+
*
|
|
58
|
+
* **The change is heard, not announced.** The items of a list or a group are
|
|
59
|
+
* the page's children, which the page or its framework adds, removes and
|
|
60
|
+
* reorders on its own, so no update of the host comes before the change. A
|
|
61
|
+
* `MutationObserver` hears children arrive, leave and change `hidden`, and
|
|
62
|
+
* each item's place before the change is the one recorded after the last
|
|
63
|
+
* change, after a resize of the host, or when the host connected.
|
|
64
|
+
*
|
|
65
|
+
* **A move interrupted by another starts from where the item is drawn.** The
|
|
66
|
+
* offset a move in flight is showing is worked out from its eased progress and
|
|
67
|
+
* added to the place it was heading for, so a second sort mid-slide carries on
|
|
68
|
+
* from the screen with no jump back.
|
|
69
|
+
*
|
|
70
|
+
* **The stylesheet decides whether anything moves.** The timing is the host
|
|
71
|
+
* family's own hooks, which `timing` reads by name so each family publishes
|
|
72
|
+
* the hooks it reads. The styled tier sets them from the duration and easing
|
|
73
|
+
* tokens, and the page can set them on the element. The headless tier sets
|
|
74
|
+
* neither, so it never moves until the page does. **Reduced motion stops
|
|
75
|
+
* every move**, whatever the properties say, because a page that writes a
|
|
76
|
+
* literal duration has not answered the reader's setting.
|
|
77
|
+
*
|
|
78
|
+
* **Places are layout pixels inside the host.** A box measured on screen is
|
|
79
|
+
* divided by the host's scale, because a move is written as a translation in
|
|
80
|
+
* the item's own pixels, and a list inside a scaled preview would otherwise
|
|
81
|
+
* travel the scale's share too far. Inside the host, so a page that scrolls
|
|
82
|
+
* while a row moves does not move its start.
|
|
83
|
+
*
|
|
84
|
+
* **An item that arrives fades in, unless every item is new.** A framework
|
|
85
|
+
* that renders the whole list again with new elements has replaced it rather
|
|
86
|
+
* than added to it, and the whole list arriving at once would be a flash.
|
|
87
|
+
* `arriveIntoEmpty` makes a list that was empty an exception, for a field
|
|
88
|
+
* whose first file or tag is the reader's own doing.
|
|
89
|
+
* The items there when the host connected arrive with the page, and do not
|
|
90
|
+
* fade.
|
|
91
|
+
*
|
|
92
|
+
* **An item with no box of its own moves as the boxes it draws.** A table's
|
|
93
|
+
* row is `display: contents`, so its cells take the move, one animation each
|
|
94
|
+
* on one curve, and a row of cells slides as one.
|
|
95
|
+
*
|
|
96
|
+
* **An item that leaves can fade where it was**, where `leaving` names a box
|
|
97
|
+
* for its copy: a field's tags, a feed's rows. Otherwise it is gone at once
|
|
98
|
+
* and the items after it slide into its room.
|
|
99
|
+
*
|
|
100
|
+
* Only `transform` and `opacity` are animated, so a move never sets off
|
|
101
|
+
* layout, and each animation is composited onto the item's own transform.
|
|
102
|
+
*/
|
|
103
|
+
export declare class LayoutMotionController implements ReactiveController {
|
|
104
|
+
private readonly host;
|
|
105
|
+
private readonly options;
|
|
106
|
+
/** Where each item was drawn after the last change. Empty until the first record. */
|
|
107
|
+
private places;
|
|
108
|
+
/** How big each item was drawn after the last change, for `leaving`. */
|
|
109
|
+
private sizes;
|
|
110
|
+
/** Whether the host has been measured once, so a change after that is a change. */
|
|
111
|
+
private recorded;
|
|
112
|
+
/** The items in the order they were drawn after the last change, which `updates` compares against. */
|
|
113
|
+
private order;
|
|
114
|
+
/** The moves in flight, by item. */
|
|
115
|
+
private readonly flights;
|
|
116
|
+
private mutations;
|
|
117
|
+
private resizes;
|
|
118
|
+
constructor(host: ReactiveControllerHost & HTMLElement, options: LayoutMotionOptions);
|
|
119
|
+
hostConnected(): void;
|
|
120
|
+
hostDisconnected(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Looks for a change once the host's update has finished, under `updates`.
|
|
123
|
+
*
|
|
124
|
+
* **A microtask later**, because a host's `updated` runs after its
|
|
125
|
+
* controllers hear `hostUpdated`, and a table assigns its rows in `updated`.
|
|
126
|
+
* Measured before that, every row was still in the order of the last sort.
|
|
127
|
+
*/
|
|
128
|
+
hostUpdated(): void;
|
|
129
|
+
/**
|
|
130
|
+
* Whether a set of records changed the items: one arriving or leaving the
|
|
131
|
+
* host or another item, as a row does a tree's branch, or turning `hidden`.
|
|
132
|
+
* A change inside an item, such as a streaming turn's text, is none.
|
|
133
|
+
*/
|
|
134
|
+
private heard;
|
|
135
|
+
/** Records where every item is drawn now, with no move started. */
|
|
136
|
+
private record;
|
|
137
|
+
/**
|
|
138
|
+
* Where each drawn item is laid out now, the offset the moves in flight are
|
|
139
|
+
* showing on top of that, and the nearest item each one sits inside. An item
|
|
140
|
+
* with no box, `hidden` or in a closed subtree, has no place.
|
|
141
|
+
*
|
|
142
|
+
* **The offset an item shows is its own move and every move around it**,
|
|
143
|
+
* because an item inside another, as a tree's branch holds its rows, is
|
|
144
|
+
* drawn wherever its parent's translation puts it.
|
|
145
|
+
*/
|
|
146
|
+
private measure;
|
|
147
|
+
/**
|
|
148
|
+
* The boxes an item is drawn in. What `boxes` names is resolved as an item
|
|
149
|
+
* is, so a heading that draws its box in its shadow root gives that box.
|
|
150
|
+
*/
|
|
151
|
+
private boxes;
|
|
152
|
+
/** The translation an item's own move in flight is drawing now, from its eased progress. */
|
|
153
|
+
private offset;
|
|
154
|
+
/**
|
|
155
|
+
* Slides every item that moved from where it was drawn to where it is now.
|
|
156
|
+
*
|
|
157
|
+
* **An item inside another moves only by the difference.** Its parent's
|
|
158
|
+
* translation already carries it, so its own starts from where it was drawn
|
|
159
|
+
* less where its parent's starts, and the two run on one curve and add up to
|
|
160
|
+
* its whole journey at every frame. An item that arrives inside another that
|
|
161
|
+
* arrives fades in with it, and does not fade a second time.
|
|
162
|
+
*/
|
|
163
|
+
private move;
|
|
164
|
+
/**
|
|
165
|
+
* Fades in an item that was not drawn before the change, settling from a
|
|
166
|
+
* little above its place.
|
|
167
|
+
*
|
|
168
|
+
* Two animations, because the fade replaces the item's opacity and the
|
|
169
|
+
* settle adds to its transform: added, an opacity from 0 would start from
|
|
170
|
+
* the item's own and never fade.
|
|
171
|
+
*/
|
|
172
|
+
private arrive;
|
|
173
|
+
/**
|
|
174
|
+
* **Copies of the items that left, fading where they were drawn**, so an
|
|
175
|
+
* item that goes does not vanish in a frame. Each is a clone laid in the
|
|
176
|
+
* `leaving` box at the item's last place and size, inert and hidden from
|
|
177
|
+
* assistive technology, shrinking a little as it fades over the first half
|
|
178
|
+
* of the move, on a curve that leaves, and gone after.
|
|
179
|
+
*
|
|
180
|
+
* Only the outermost of what left: a row's own items go with its copy.
|
|
181
|
+
* Not a list replaced whole, which is new rather than changed.
|
|
182
|
+
*/
|
|
183
|
+
private leave;
|
|
184
|
+
/** Ends an item's move in flight where it is, for a new one to start from. */
|
|
185
|
+
private land;
|
|
186
|
+
}
|