kuinetic 0.2.4 → 0.4.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/README.md +2 -2
- package/dist/esm/advanced/index.mjs +1 -1
- package/dist/esm/{chunk-FASAEQDR.mjs → chunk-CG37RODK.mjs} +1232 -277
- package/dist/esm/{chunk-AEQGC2KM.mjs → chunk-EDFJTT5B.mjs} +2 -1
- package/dist/esm/{chunk-MZQG2VMG.mjs → chunk-W7U4A2NK.mjs} +708 -610
- package/dist/esm/{chunk-EHS45PIK.mjs → chunk-Y2FP56K5.mjs} +9228 -4275
- package/dist/esm/core/index.mjs +3 -3
- package/dist/esm/effects/index.mjs +3 -3
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/notes/index.mjs +347 -9
- package/dist/kuinetic.advanced.js +2 -1
- package/dist/kuinetic.advanced.min.js +1 -1
- package/dist/kuinetic.all.js +9099 -3152
- package/dist/kuinetic.all.min.js +4 -2
- package/dist/kuinetic.css +2408 -161
- package/dist/kuinetic.js +9098 -3151
- package/dist/kuinetic.min.css +1 -1
- package/dist/kuinetic.min.js +3 -1
- package/dist/kuinetic.notes.js +1 -1
- package/dist/types/advanced/shaders.d.ts +1 -1
- package/dist/types/core/animator.d.ts +61 -2
- package/dist/types/core/attrs.d.ts +0 -2
- package/dist/types/core/auto-motion.d.ts +139 -0
- package/dist/types/core/cadence.d.ts +90 -0
- package/dist/types/core/channels.d.ts +5 -1
- package/dist/types/core/compile.d.ts +14 -2
- package/dist/types/core/deck-viewer.d.ts +2 -0
- package/dist/types/core/declarations.d.ts +6 -0
- package/dist/types/core/derived/group-gate.d.ts +18 -4
- package/dist/types/core/describe.d.ts +1 -1
- package/dist/types/core/easing.d.ts +9 -0
- package/dist/types/core/effect-context.d.ts +5 -0
- package/dist/types/core/element-config.d.ts +5 -4
- package/dist/types/core/flip.d.ts +25 -1
- package/dist/types/core/gesture.d.ts +5 -0
- package/dist/types/core/image-flight.d.ts +23 -0
- package/dist/types/core/instances.d.ts +27 -3
- package/dist/types/core/js-effect-preparer.d.ts +3 -1
- package/dist/types/core/owned-styles.d.ts +2 -1
- package/dist/types/core/params.d.ts +2 -3
- package/dist/types/core/parse.d.ts +21 -1
- package/dist/types/core/pause-scope.d.ts +40 -0
- package/dist/types/core/play.d.ts +2 -2
- package/dist/types/core/registry.d.ts +17 -2
- package/dist/types/core/repeat.d.ts +6 -4
- package/dist/types/core/sequence.d.ts +10 -0
- package/dist/types/core/stagger-config.d.ts +23 -101
- package/dist/types/core/stagger-keys.d.ts +2 -4
- package/dist/types/core/stagger.d.ts +12 -21
- package/dist/types/core/types.d.ts +76 -19
- package/dist/types/effects/auto-motion.d.ts +22 -117
- package/dist/types/effects/carousel/archive.d.ts +18 -0
- package/dist/types/effects/carousel/coast.d.ts +7 -0
- package/dist/types/effects/carousel/deck.d.ts +31 -2
- package/dist/types/effects/carousel/drag.d.ts +24 -7
- package/dist/types/effects/carousel/glide.d.ts +89 -0
- package/dist/types/effects/carousel/line.d.ts +10 -0
- package/dist/types/effects/carousel/row-copies.d.ts +13 -0
- package/dist/types/effects/carousel/row.d.ts +3 -0
- package/dist/types/effects/carousel/shape-fit.d.ts +54 -0
- package/dist/types/effects/carousel/sources.d.ts +26 -0
- package/dist/types/effects/carousel/sphere.d.ts +23 -0
- package/dist/types/effects/carousel/stack.d.ts +2 -1
- package/dist/types/effects/catalog/confetti.d.ts +2 -0
- package/dist/types/effects/catalog/cursor-trail.d.ts +2 -0
- package/dist/types/effects/catalog/curtains.d.ts +2 -0
- package/dist/types/effects/catalog/feedback.d.ts +1 -1
- package/dist/types/effects/catalog/image-flight.d.ts +2 -0
- package/dist/types/effects/catalog/line-boil.d.ts +2 -0
- package/dist/types/effects/catalog/media-shared.d.ts +10 -0
- package/dist/types/effects/catalog/number-tokens.d.ts +5 -0
- package/dist/types/effects/catalog/numbers-shared.d.ts +3 -4
- package/dist/types/effects/catalog/pause-scope.d.ts +20 -0
- package/dist/types/effects/catalog/text-shared.d.ts +17 -6
- package/dist/types/effects/catalog/typewriter-scatter.d.ts +5 -0
- package/dist/types/effects/catalog/view-transitions.d.ts +32 -1
- package/dist/types/effects/catalog/wobble.d.ts +2 -0
- package/dist/types/effects/gestures/drag-options.d.ts +17 -0
- package/dist/types/effects/layout/departures.d.ts +21 -0
- package/dist/types/effects/motion-path/fit.d.ts +4 -0
- package/dist/types/effects/scroll-mechanics/progress-output.d.ts +9 -0
- package/dist/types/effects/scroll-mechanics/snap-autoplay.d.ts +20 -0
- package/dist/types/effects/step-index.d.ts +19 -1
- package/dist/types/effects/step-marking.d.ts +7 -4
- package/dist/types/effects/svg/morph-loop.d.ts +7 -0
- package/dist/types/effects/svg/text-path.d.ts +2 -0
- package/dist/types/effects/three-d/cube.d.ts +2 -0
- package/dist/types/effects/tween/index.d.ts +2 -1
- package/dist/types/effects/tween/properties.d.ts +1 -1
- package/dist/types/effects/tween/toggle.d.ts +6 -0
- package/dist/types/effects/tween/waypoints.d.ts +1 -1
- package/dist/types/notes/effects.d.ts +1 -0
- package/dist/types/notes/index.d.ts +11 -0
- package/dist/types/notes/showcase.d.ts +1 -0
- package/dist/types/showcase/lightbox-flight.d.ts +11 -0
- package/dist/types/showcase/media-source.d.ts +1 -0
- package/dist/types/showcase/modal-shell.d.ts +5 -0
- package/dist/types/showcase/youtube.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,127 +1,27 @@
|
|
|
1
|
+
import { clampPeriod, createAutoMotion } from '../core/auto-motion.js';
|
|
2
|
+
import type { AutoMotion, AutoMotionRequest } from '../core/auto-motion.js';
|
|
1
3
|
import type { PrepareContext } from '../core/effect-context.js';
|
|
2
4
|
import type { Cleanup, EffectParams, ParamSpec } from '../core/types.js';
|
|
3
5
|
import type { ControlGroup } from './step-index.js';
|
|
6
|
+
export { clampPeriod, createAutoMotion };
|
|
7
|
+
export type { AutoMotion, AutoMotionRequest };
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
9
|
+
* Make the author's pause control hold every other clock-driven effect on the same host.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Effects composed on one element (`starfield, carousel-warp autoplay:6s`) each own a separate
|
|
12
|
+
* kind of motion, but a visitor sees one pause button and expects the whole element to stop
|
|
13
|
+
* (WCAG 2.2.2). Compiled CSS effects are gated by `animation-play-state` on the host, which is the
|
|
14
|
+
* property `control().pause()` writes, through the host's own style ledger (`ctx.style`, the same
|
|
15
|
+
* ledger object the CSS instances use). Writing it here, through that ledger, reaches every such
|
|
16
|
+
* effect on the host without this widget knowing which ones they are, and unwinds with them on
|
|
17
|
+
* teardown. It writes nothing until a pause is first pressed, so an unpaused widget leaves the
|
|
18
|
+
* other effects' own play state alone.
|
|
13
19
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* offscreen, reduced motion, the author's pause control), how to yield to a person (a drag or a
|
|
18
|
-
* control press takes over, then the motion resumes from wherever the deck was left), how to hand
|
|
19
|
-
* the transition back and forth (a frame-driven spin must not also be eased), and how to tear down.
|
|
20
|
-
*
|
|
21
|
-
* ## Why `requestAnimationFrame` writing the deck's own position, and not a CSS animation
|
|
22
|
-
*
|
|
23
|
-
* The obvious CSS answer — register `--kui-step-position` with `@property` and run an infinite
|
|
24
|
-
* linear `@keyframes` over it — fails the one requirement that matters most here: a drag, a click
|
|
25
|
-
* and the spin must all move *one* number. A CSS animation owns its value; the drag would have to
|
|
26
|
-
* read the animated position back out of `getComputedStyle` at `pointerdown`, cancel the animation,
|
|
27
|
-
* drive the deck from JavaScript, and then restart the keyframe at a negative `animation-delay`
|
|
28
|
-
* computed to land on wherever the release settled. That is two sources of truth reconciled by
|
|
29
|
-
* arithmetic on every hand-off, and the "no snap-back when spin resumes" requirement is precisely
|
|
30
|
-
* the bug that reconciliation produces when it is off by one frame.
|
|
31
|
-
*
|
|
32
|
-
* Writing the continuous `position` the deck already has (the same number the drag moves and the
|
|
33
|
-
* controls set) makes the hand-off free: pausing is "stop adding to it", resuming is "start adding
|
|
34
|
-
* to it again", and a drag in between simply moved it. It costs nothing the CSS route would have
|
|
35
|
-
* saved — an animated custom property is recomputed on the main thread either way, because the
|
|
36
|
-
* geometry reading it is a `calc()` the compositor cannot run.
|
|
37
|
-
*
|
|
38
|
-
* `autoplay:` does not need frames at all: it is a timer that presses "next", and the stylesheet's
|
|
39
|
-
* own transition does the travel, exactly as it does for a click. Same model as
|
|
40
|
-
* `showcase/slideshow.ts`'s `autoplay:`, whose pause rules this mirrors.
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* The shortest period either kind of motion may be set to, in milliseconds.
|
|
44
|
-
*
|
|
45
|
-
* The same floor `slideshow`'s `autoplay:` has and for the same reason: below it, content moves
|
|
46
|
-
* faster than it can be read, and a whole ring turning in under two seconds is a strobe rather than
|
|
47
|
-
* a carousel. Clamped with a warning rather than refused, so a typo still produces a working deck.
|
|
48
|
-
*/
|
|
49
|
-
export declare const MIN_PERIOD_MS = 2000;
|
|
50
|
-
/**
|
|
51
|
-
* The longest frame a spin will integrate over, in milliseconds.
|
|
52
|
-
*
|
|
53
|
-
* A dropped frame or a debugger pause otherwise arrives as one enormous `dt` and the ring leaps.
|
|
54
|
-
* Capping it turns a hitch into a brief slow-down, which is the less surprising failure. Resuming
|
|
55
|
-
* from a pause never relies on this — the first frame after a resume only records its timestamp.
|
|
56
|
-
*/
|
|
57
|
-
export declare const MAX_FRAME_MS = 100;
|
|
58
|
-
/**
|
|
59
|
-
* An authored signed period, floored to {@link MIN_PERIOD_MS} in magnitude.
|
|
60
|
-
*
|
|
61
|
-
* Pure and exported so the clamp and the sign rule are assertable without a clock. `0` means off
|
|
62
|
-
* and stays `0`; the sign is the direction and survives the clamp.
|
|
63
|
-
*
|
|
64
|
-
* @param ms - Authored period in milliseconds; negative runs backwards.
|
|
65
|
-
* @returns The period to run at, or `0` for off.
|
|
66
|
-
* @complexity O(1) time and space.
|
|
67
|
-
*/
|
|
68
|
-
export declare function clampPeriod(ms: number): number;
|
|
69
|
-
/**
|
|
70
|
-
* How far one frame advances the deck, in whole cycles of it.
|
|
71
|
-
*
|
|
72
|
-
* A cycle is every slide passing once — one revolution of a full ring. Expressed in cycles rather
|
|
73
|
-
* than places so the rate an author writes (`spin:40s`) is independent of how many slides there
|
|
74
|
-
* are: adding a card to a 40-second ring keeps it a 40-second ring rather than slowing each card.
|
|
75
|
-
*
|
|
76
|
-
* @param dtMs - Milliseconds since the previous frame, before capping.
|
|
77
|
-
* @param periodMs - Signed milliseconds per cycle; non-zero.
|
|
78
|
-
* @complexity O(1) time and space.
|
|
20
|
+
* @param ctx - The widget's prepare context; `ctx.style` is the host's ledger.
|
|
21
|
+
* @returns A setter: `true` holds the host's other effects, `false` lets them run again.
|
|
22
|
+
* @complexity O(1) time and space per call.
|
|
79
23
|
*/
|
|
80
|
-
export declare function
|
|
81
|
-
export interface AutoMotionRequest {
|
|
82
|
-
el: Element;
|
|
83
|
-
ctx: PrepareContext;
|
|
84
|
-
/** Signed milliseconds per full cycle of continuous spin, already clamped; `0` is off. */
|
|
85
|
-
spinMs: number;
|
|
86
|
-
/** Signed milliseconds between autoplay steps, already clamped; `0` is off. */
|
|
87
|
-
autoplayMs: number;
|
|
88
|
-
/** How long a manual move takes to settle, so the motion does not resume mid-transition. */
|
|
89
|
-
settleMs: number;
|
|
90
|
-
/** Whether the pointer resting on the deck pauses it. Omitted, it does. See `HOVER_PARAM`. */
|
|
91
|
-
pauseOnHover?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Move the deck on by a (signed) fraction of a full cycle. Absent on a deck that cannot spin; such
|
|
94
|
-
* a deck always has `spinMs` 0 (`motionPeriods`), so nothing ever calls it.
|
|
95
|
-
*/
|
|
96
|
-
advance?(cycles: number): void;
|
|
97
|
-
/** Step the deck one place. */
|
|
98
|
-
step(direction: 1 | -1): void;
|
|
99
|
-
/**
|
|
100
|
-
* Publish whether frames, rather than the stylesheet's transition, are driving the deck. Absent,
|
|
101
|
-
* and never called, on a deck that cannot spin — see `advance`.
|
|
102
|
-
*/
|
|
103
|
-
setSpinning?(spinning: boolean): void;
|
|
104
|
-
/** Called whenever the author-facing paused state changes, to mirror it onto pause controls. */
|
|
105
|
-
onPausedChange(paused: boolean): void;
|
|
106
|
-
}
|
|
107
|
-
export interface AutoMotion {
|
|
108
|
-
/** Whether any motion was configured at all. */
|
|
109
|
-
readonly enabled: boolean;
|
|
110
|
-
/** A person moved the deck: hand the transition back and hold off for one settle period. */
|
|
111
|
-
interrupt(): void;
|
|
112
|
-
/** A gesture is (or is no longer) in progress; nothing moves on its own while one is. */
|
|
113
|
-
hold(holding: boolean): void;
|
|
114
|
-
/** The author's pause control was pressed. */
|
|
115
|
-
toggle(): void;
|
|
116
|
-
release: Cleanup;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Start the deck's own motion and return the handle its manual inputs talk to.
|
|
120
|
-
*
|
|
121
|
-
* @returns A controller; `enabled` is false (and every method inert) when neither motion was set.
|
|
122
|
-
* @complexity O(1) per event and per frame; O(1) space.
|
|
123
|
-
*/
|
|
124
|
-
export declare function createAutoMotion(request: AutoMotionRequest): AutoMotion;
|
|
24
|
+
export declare function createHostPlayhead(ctx: PrepareContext): (paused: boolean) => void;
|
|
125
25
|
export declare const AUTOPLAY_PARAM: ParamSpec;
|
|
126
26
|
export declare const PAUSE_PARAM: ParamSpec;
|
|
127
27
|
export declare const HOVER_PARAM: ParamSpec;
|
|
@@ -136,6 +36,8 @@ export interface DeckMotionRequest {
|
|
|
136
36
|
settleMs: number;
|
|
137
37
|
/** Step the deck one place. */
|
|
138
38
|
step(direction: 1 | -1): void;
|
|
39
|
+
onAutoplayProgress?: AutoMotionRequest['onAutoplayProgress'];
|
|
40
|
+
generatedPause?: HTMLButtonElement;
|
|
139
41
|
/**
|
|
140
42
|
* The continuous half, for a deck that has a continuous position to spin (`spin:`). Omitted, the
|
|
141
43
|
* deck has no `spin:` parameter and only `autoplay:` is read.
|
|
@@ -163,6 +65,9 @@ export interface DeckMotion {
|
|
|
163
65
|
* read the same parameters, warn the same way and reflect pause the same way — the only things a
|
|
164
66
|
* deck supplies are how it steps and, if it spins, how it advances.
|
|
165
67
|
*
|
|
68
|
+
* A pause carried over from the deck this one replaced is taken up only if there is a control to lift
|
|
69
|
+
* it: a deck left stopped with no way to restart it would be worse than one that moves.
|
|
70
|
+
*
|
|
166
71
|
* @complexity O(1) at setup plus one scoped query for a named `pause:`; O(m) per pause toggle in the
|
|
167
72
|
* matched controls.
|
|
168
73
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { createAttributeLedger, StyleLedger } from '../../core/owned-styles.js';
|
|
3
|
+
import type { EffectParams } from '../../core/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The bounded half of `shape:line attribute:`: the app names the arrangement, this answers where a
|
|
6
|
+
* place is in the column. The flex row stays the only layout, so the switch is one transform
|
|
7
|
+
* interpolation. Heights are read at row measurement boundaries, never during a flight.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createArchive(host: HTMLElement, params: EffectParams, ctx: PrepareContext, attributes: ReturnType<typeof createAttributeLedger>): {
|
|
10
|
+
isColumn: () => boolean;
|
|
11
|
+
pixelAt: (place: number) => number;
|
|
12
|
+
bound: (place: number) => number | undefined;
|
|
13
|
+
positionAt: (from: number, dy: number) => number;
|
|
14
|
+
measure(slides: readonly HTMLElement[], styles: ReadonlyMap<Element, StyleLedger>): void;
|
|
15
|
+
/** Hold the deck's own motion too: a spin frame would restart every card's staggered delay. */
|
|
16
|
+
fly(live: number, slides: readonly HTMLElement[], styles: ReadonlyMap<Element, StyleLedger>, hold: (holding: boolean) => void): void;
|
|
17
|
+
watch(onSwitch: () => void): () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
/** A finite pixel coast; the deck keeps ownership of position and its motion hold. */
|
|
3
|
+
export declare function createCoast(el: Element, ctx: PrepareContext, move: (dx: number) => void, done: () => void): {
|
|
4
|
+
stop: () => void;
|
|
5
|
+
start(velocity: number, baseline?: number): void;
|
|
6
|
+
release(): void;
|
|
7
|
+
};
|
|
@@ -39,8 +39,8 @@ export declare const SPINNING_ATTR = "data-kui-ring-spinning";
|
|
|
39
39
|
* A published fact rather than a CSS derivation, because it is a branch on the sign or magnitude of
|
|
40
40
|
* a `calc()`, which CSS cannot take. The ring answers it with "is this slot's plane turned more
|
|
41
41
|
* than a quarter turn away" (`faceAt`); the stack with "has it left the visible depth". The
|
|
42
|
-
* stylesheet hangs `pointer-events` on it for every shape
|
|
43
|
-
*
|
|
42
|
+
* stylesheet hangs `pointer-events` on it for every shape; `inert` also takes back-facing slots
|
|
43
|
+
* and their descendants out of the tab order without hiding the outward ring.
|
|
44
44
|
*
|
|
45
45
|
* That matters for more than tidiness. A card turned away from the viewer still occupies its
|
|
46
46
|
* projected screen rectangle for hit-testing purposes — `backface-visibility: hidden` stops it
|
|
@@ -62,6 +62,8 @@ export type Face = 'front' | 'back';
|
|
|
62
62
|
* it, and the next change to that slot transitions normally.
|
|
63
63
|
*/
|
|
64
64
|
export declare const WRAP_ATTR = "data-kui-ring-wrap";
|
|
65
|
+
/** Commit a layout change while its transitions are suspended, then restore the author's flag. */
|
|
66
|
+
export declare function commitWithoutTransition(win: Window, node: Element, write?: () => void): void;
|
|
65
67
|
/**
|
|
66
68
|
* Which way a deck's cards travel across the screen as its position grows, as the sign a drag's
|
|
67
69
|
* pixels are multiplied by: `1` when the next card sits to the right of the live one (so advancing
|
|
@@ -123,12 +125,38 @@ export declare function snapPosition(position: number, total: number): {
|
|
|
123
125
|
export declare const DECK_PARAMETERS: ParameterSchema;
|
|
124
126
|
/** What a deck's shape contributes; everything else is shared. */
|
|
125
127
|
export interface DeckLayout {
|
|
128
|
+
coastSpeed?(spinMs: number): number;
|
|
129
|
+
unwrapped?: boolean;
|
|
130
|
+
advanceBoth?: boolean;
|
|
131
|
+
/** Optional shape-specific pointer travel in pixels per card. */
|
|
132
|
+
travelPx?: number;
|
|
126
133
|
/** The primitive's id: names the mirrored timing properties (`--kui-<id>-duration`). */
|
|
127
134
|
id: string;
|
|
128
135
|
/** Prefix for warnings, the word an author would recognise. */
|
|
129
136
|
label: string;
|
|
130
137
|
/** Whether a slot at this place is presented to the viewer. `place` is `offset - drift`. */
|
|
131
138
|
faceOf(place: number, offset: number, count: number): Face;
|
|
139
|
+
/** A depth ring's cached view through author transforms; absent for other layouts. */
|
|
140
|
+
view?: {
|
|
141
|
+
measure(nodes: readonly Element[]): void;
|
|
142
|
+
faceOf(place: number, count: number, index: number): Face | undefined;
|
|
143
|
+
travelSign(): 1 | -1 | undefined;
|
|
144
|
+
keyboardSign?(): 1 | -1;
|
|
145
|
+
pixelPosition?(): number;
|
|
146
|
+
pickup?(position: number): number | undefined;
|
|
147
|
+
watch(refresh: () => void, goTo: (position: number) => void, hold: (holding: boolean) => void): Cleanup;
|
|
148
|
+
render?(position: number): void;
|
|
149
|
+
positionAt?(from: number, dx: number, dy?: number): number;
|
|
150
|
+
/** A shape with real ends clamps a place; `undefined` means it is circular right now. */
|
|
151
|
+
bound?(position: number): number | undefined;
|
|
152
|
+
};
|
|
153
|
+
/** A second drag axis, for a shape that has one. */
|
|
154
|
+
pitch?: {
|
|
155
|
+
begin(): void;
|
|
156
|
+
move(turns: number): void;
|
|
157
|
+
};
|
|
158
|
+
/** `'y'` when the ring is a drum (`axis:x`) and a vertical drag turns it. */
|
|
159
|
+
dragAxis?: 'x' | 'y';
|
|
132
160
|
/**
|
|
133
161
|
* The shape's own reading of a circular offset, when it is not the offset itself.
|
|
134
162
|
*
|
|
@@ -139,6 +167,7 @@ export interface DeckLayout {
|
|
|
139
167
|
placeOf?(offset: number, count: number): number;
|
|
140
168
|
/** Whether to publish the first slot's measured size for a stylesheet that derives from it. */
|
|
141
169
|
measure: boolean;
|
|
170
|
+
repeat?(originals: readonly Element[]): Element[];
|
|
142
171
|
/** Attributes the shape publishes on the host, so its selectors can branch on parameters. */
|
|
143
172
|
hostAttributes?: Record<string, string>;
|
|
144
173
|
/**
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
2
|
import type { Cleanup } from '../../core/types.js';
|
|
3
3
|
export interface RingDragRequest {
|
|
4
|
+
unwrapped?: boolean;
|
|
5
|
+
pickup?(): void;
|
|
6
|
+
keyboardSign?(): 1 | -1;
|
|
7
|
+
free?: boolean;
|
|
8
|
+
coastSpeed(): number;
|
|
9
|
+
moveFree?(position: number): void;
|
|
10
|
+
advanceBoth?: boolean;
|
|
4
11
|
el: Element;
|
|
5
12
|
ctx: PrepareContext;
|
|
6
13
|
/** `grab:false` still installs the keyboard half — that is accessibility, not decoration. */
|
|
@@ -17,6 +24,19 @@ export interface RingDragRequest {
|
|
|
17
24
|
* the card under the pointer follows it whatever the shape.
|
|
18
25
|
*/
|
|
19
26
|
travelSign(): 1 | -1;
|
|
27
|
+
positionAt?(from: number, dx: number, dy?: number): number;
|
|
28
|
+
/** A shape with real ends clamps a place before a key press can wrap it. */
|
|
29
|
+
bound?(place: number): number | undefined;
|
|
30
|
+
/** A second axis: the gesture recognises either direction, and touch-action stays pan-y. */
|
|
31
|
+
pitch?: {
|
|
32
|
+
begin(): void;
|
|
33
|
+
move(turns: number): void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* `'y'` for a drum (`axis:x`): the vertical movement turns it, dragging down advances it (the card
|
|
37
|
+
* waiting at the top follows the hand down). Absent or `'x'` is the ring's horizontal drag.
|
|
38
|
+
*/
|
|
39
|
+
dragAxis?: 'x' | 'y';
|
|
20
40
|
/** Move the ring to a continuous position and re-render. */
|
|
21
41
|
moveTo(position: number): void;
|
|
22
42
|
/** Publish or clear the dragging state the stylesheet suspends its transition on. */
|
|
@@ -77,10 +97,7 @@ export declare function snapTo(projected: number): number;
|
|
|
77
97
|
* @complexity O(1) time and space.
|
|
78
98
|
*/
|
|
79
99
|
export declare function wrapPlace(place: number, total: number): number;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* @complexity O(1) per pointer event and per key; O(1) space.
|
|
85
|
-
*/
|
|
86
|
-
export declare function createRingDrag(request: RingDragRequest): Cleanup;
|
|
100
|
+
export declare function nearestPlace(place: number, current: number, total: number): number;
|
|
101
|
+
export declare function createRingDrag(request: RingDragRequest): Cleanup & {
|
|
102
|
+
interrupt(): void;
|
|
103
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Cleanup } from '../../core/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Changing a live deck's effect: the cards glide from where they are to where the new shape wants them.
|
|
4
|
+
*
|
|
5
|
+
* Setting `data-kui` reinstalls the effect, and between the two shapes three things change at once:
|
|
6
|
+
* each card's transform, its layout box (a grid cell becomes a place in a flex row, a stack's padding
|
|
7
|
+
* comes or goes), and the host's camera. A CSS transition can only ever see the first, and only when
|
|
8
|
+
* nothing resolves style between teardown and install. So it flew some pairs by luck and jumped
|
|
9
|
+
* others. This file is the one owner of that move, and the transition stays out of it.
|
|
10
|
+
*
|
|
11
|
+
* ## A pose, not a box
|
|
12
|
+
*
|
|
13
|
+
* `core/flip.ts` measures bounding boxes, and that is the wrong record here: the box of a card turned
|
|
14
|
+
* sixty degrees on a ring says nothing about the turn, so a FLIP from it would flatten the picture on
|
|
15
|
+
* the first frame. What is recorded is the card's whole mapping to the page: the host's camera and
|
|
16
|
+
* scale, then the card's layout position, then its computed transform. On arrival that mapping is
|
|
17
|
+
* re-expressed under the *new* camera and the new layout box, which gives the one transform that
|
|
18
|
+
* paints the card exactly where it was. Computed values, so a card caught mid-glide or mid-step
|
|
19
|
+
* records where it is right now.
|
|
20
|
+
*
|
|
21
|
+
* Layout positions are `offsetLeft` chains rather than rects. They ignore every transform, including
|
|
22
|
+
* an ancestor's, so the arithmetic stays in one coordinate space whatever the page does above the deck.
|
|
23
|
+
*
|
|
24
|
+
* ## One start keyframe, no end keyframe
|
|
25
|
+
*
|
|
26
|
+
* Each animation names only its start and leaves the end to the underlying value. So a spin, a drag
|
|
27
|
+
* or an arrow press during the glide changes the target and the card follows, and nothing has to
|
|
28
|
+
* cancel anything. It also writes nothing inline: when it ends, the stylesheet is simply back.
|
|
29
|
+
*
|
|
30
|
+
* ## The transition has to sit out exactly one moment
|
|
31
|
+
*
|
|
32
|
+
* `arriving` holds `transition-property: none` while the new shape is stamped and committed, so the
|
|
33
|
+
* install itself starts no transition. That also covers any forced style read during install, such as
|
|
34
|
+
* the flattening check before a ring places its cards, which used to commit `transform: none` and fly
|
|
35
|
+
* every card out from the host's centre. `flying` restores the transition before the first frame, so
|
|
36
|
+
* a later step travels as usual underneath the glide. Two layers, never over the same change.
|
|
37
|
+
*
|
|
38
|
+
* ## A row's box and its copies
|
|
39
|
+
*
|
|
40
|
+
* A row clips, and it stops clipping for the length of the glide, because a ring's cards stand outside
|
|
41
|
+
* its box. So a card past the row's edge is treated as out of sight at either end. Leaving a row it
|
|
42
|
+
* fades in rather than popping into view when the clip lets go. Arriving at a row it fades out rather
|
|
43
|
+
* than blinking away when the clip comes back. A card across the edge meets a clip that moves.
|
|
44
|
+
*
|
|
45
|
+
* Copies have no pose to glide between, since they exist in one shape only, so they cross-fade. The
|
|
46
|
+
* new row's fade in where they stand. The old row's, already taken out by its teardown, go back in the
|
|
47
|
+
* host out of flow for as long as they take to fade out where they stood. `deck.ts` never counts a copy
|
|
48
|
+
* as a slide, so no deck picks one up.
|
|
49
|
+
*/
|
|
50
|
+
/** Attribute on the host, from the start of the install until the last card lands. */
|
|
51
|
+
export declare const GLIDE_ATTR = "data-kui-deck-glide";
|
|
52
|
+
/** A 4x4 matrix in column order, as `matrix3d()` spells it. */
|
|
53
|
+
type Matrix = readonly number[];
|
|
54
|
+
/**
|
|
55
|
+
* A computed `transform` as a matrix: the browser only ever resolves one to these three spellings.
|
|
56
|
+
*
|
|
57
|
+
* @complexity O(1) time and space.
|
|
58
|
+
*/
|
|
59
|
+
export declare function matrixOf(value: string): Matrix;
|
|
60
|
+
/**
|
|
61
|
+
* Note where a departing deck's cards are, for a deck that takes over this host in this same task.
|
|
62
|
+
*
|
|
63
|
+
* Call before anything is restored. The microtask is the expiry: a reinstall is synchronous, so a
|
|
64
|
+
* recording still here afterwards means the new effect was not a deck, and it must not reach a deck
|
|
65
|
+
* installed long after, when these poses describe nothing on screen. Skipped where the Web Animations
|
|
66
|
+
* API is missing, since nothing could play it.
|
|
67
|
+
*
|
|
68
|
+
* @complexity O(n) time in cards; one forced layout.
|
|
69
|
+
*/
|
|
70
|
+
export declare function recordDeckPoses(host: HTMLElement, nodes: readonly Element[], win: Window): void;
|
|
71
|
+
export interface GlideTiming {
|
|
72
|
+
durationMs: number;
|
|
73
|
+
easing: string;
|
|
74
|
+
/** Land immediately: the new arrangement, with no travel. */
|
|
75
|
+
reducedMotion: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** A deck taking over from another: land its cards once they are placed. */
|
|
78
|
+
export type DeckArrival = (nodes: readonly Element[], timing: GlideTiming, win: Window) => Cleanup;
|
|
79
|
+
/**
|
|
80
|
+
* Claim a recording for a deck installing on this host, and hold its transition off.
|
|
81
|
+
*
|
|
82
|
+
* Call before the deck writes anything. No recording means this is not a switch: a first load, or
|
|
83
|
+
* a host that had some other effect, and those are exactly as they were.
|
|
84
|
+
*
|
|
85
|
+
* @returns How to land the cards once they are placed, or `undefined`.
|
|
86
|
+
* @complexity O(1) time and space.
|
|
87
|
+
*/
|
|
88
|
+
export declare function claimDeckArrival(host: HTMLElement): DeckArrival | undefined;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { EffectParams } from '../../core/types.js';
|
|
3
|
+
export interface LineGeometry {
|
|
4
|
+
stride: number;
|
|
5
|
+
cycle: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
/** Geometry is read at row measurement boundaries, never while the row moves. */
|
|
10
|
+
export declare function createLine(host: HTMLElement, params: EffectParams, ctx: PrepareContext): (geometry: LineGeometry) => number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
/** Marks a row's extra image. It is never a slide, whatever selector the deck was given. */
|
|
3
|
+
export declare const ROW_COPY_ATTR = "data-kui-row-copy";
|
|
4
|
+
export declare const RING_COPY_ATTR = "data-kui-ring-copy";
|
|
5
|
+
/** Copy only an image's visuals, never its IDs, effects or semantics. */
|
|
6
|
+
export declare function copySlideImage(image: HTMLImageElement): HTMLImageElement;
|
|
7
|
+
/** Image sources can change without changing a fixed-size image's observed box. */
|
|
8
|
+
export declare function watchCopySources(host: Element, ctx: PrepareContext, refresh: () => void): () => void;
|
|
9
|
+
/** Fresh image visuals only: never duplicate links, IDs, effects or semantic slides. */
|
|
10
|
+
export declare function createRowCopies(host: Element, ctx: PrepareContext): {
|
|
11
|
+
clear: () => void;
|
|
12
|
+
measure(slides: readonly HTMLElement[], widths: number[], cycle: number, required: number): HTMLImageElement[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { StyleLedger } from '../../core/owned-styles.js';
|
|
3
|
+
import type { EffectParams } from '../../core/types.js';
|
|
4
|
+
export interface ProjectedBounds {
|
|
5
|
+
minX: number;
|
|
6
|
+
maxX: number;
|
|
7
|
+
minY: number;
|
|
8
|
+
maxY: number;
|
|
9
|
+
}
|
|
10
|
+
export interface HelixGeometry {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
radius: number;
|
|
14
|
+
rise: number;
|
|
15
|
+
count: number;
|
|
16
|
+
arc: number;
|
|
17
|
+
tilt: number;
|
|
18
|
+
perspective: number;
|
|
19
|
+
camera: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** The fade seam is centered half a place away from zero for an even circular numbering. */
|
|
22
|
+
export declare function helixCentre(count: number): number;
|
|
23
|
+
/** Project the CSS helix's card corners across its reachable places, once per geometry change. */
|
|
24
|
+
export declare function projectHelix(g: HelixGeometry): ProjectedBounds;
|
|
25
|
+
/** A shared two-dimensional scale bound; old rings retain their radius-only solver. */
|
|
26
|
+
export declare function fitProjectedBounds(bounds: ProjectedBounds, room: {
|
|
27
|
+
left: number;
|
|
28
|
+
right: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}): number;
|
|
31
|
+
export interface ShapeFitRequest {
|
|
32
|
+
el: Element;
|
|
33
|
+
ctx: PrepareContext;
|
|
34
|
+
styles: StyleLedger;
|
|
35
|
+
params: EffectParams;
|
|
36
|
+
arc: number;
|
|
37
|
+
tilt: number;
|
|
38
|
+
sphere?: boolean;
|
|
39
|
+
drum?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A drum's silhouette: `translateZ(-r) rotateY(t) rotateX(a) translateZ(r)` applied to each corner.
|
|
43
|
+
*
|
|
44
|
+
* Only the front half is sampled, because `backface-visibility: hidden` hides the rest, so the
|
|
45
|
+
* reach is the cards that can actually be seen. The host's own `rotateY(t)` is the ring tilt.
|
|
46
|
+
*/
|
|
47
|
+
export declare function projectDrum(g: HelixGeometry): ProjectedBounds;
|
|
48
|
+
/** A sphere's silhouette is a circle at any rotation, so it needs no sampling and stays right under a second axis. */
|
|
49
|
+
export declare function projectSphere(g: HelixGeometry): ProjectedBounds;
|
|
50
|
+
/** Observe geometry only; the moving deck never asks this solver for a frame. */
|
|
51
|
+
export declare function createHelixFit(request: ShapeFitRequest): {
|
|
52
|
+
render(elements: readonly Element[], count: number): void;
|
|
53
|
+
release(): void;
|
|
54
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { StyleLedger } from '../../core/owned-styles.js';
|
|
3
|
+
import type { EffectParams, EffectSpec, EffectVariant } from '../../core/types.js';
|
|
4
|
+
export declare function deckSourceVariant(spec: EffectSpec): EffectVariant;
|
|
5
|
+
/** A scroll-driven deck has one source; its clock must not write over the scroller. */
|
|
6
|
+
export declare function deckMotionParams(params: EffectParams, ctx: PrepareContext, label: string): EffectParams;
|
|
7
|
+
/** Physical pixels per second, sampled after the single position writer has rendered. */
|
|
8
|
+
export declare function createDeckSpeed(ctx: PrepareContext, styles: StyleLedger): {
|
|
9
|
+
reset: () => void;
|
|
10
|
+
sample(pixel: number, discrete: boolean): void;
|
|
11
|
+
release(): void;
|
|
12
|
+
};
|
|
13
|
+
interface ScrollDeck {
|
|
14
|
+
el: Element;
|
|
15
|
+
params: EffectParams;
|
|
16
|
+
ctx: PrepareContext;
|
|
17
|
+
count(): number;
|
|
18
|
+
position(): number;
|
|
19
|
+
dragging(): boolean;
|
|
20
|
+
move(position: number): void;
|
|
21
|
+
resetSpeed(): void;
|
|
22
|
+
driving(active: boolean): void;
|
|
23
|
+
}
|
|
24
|
+
/** A grab rebases the scroll source instead of letting a dirty scroll frame steal it. */
|
|
25
|
+
export declare function trackDeckScroll(request: ScrollDeck): () => void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { DeckAttachment } from './deck.js';
|
|
3
|
+
import type { ShapeFitRequest } from './shape-fit.js';
|
|
4
|
+
/**
|
|
5
|
+
* One added latitude per card, in degrees, spread for equal area. Longitude stays `place * spacing`,
|
|
6
|
+
* so the live card, the wrap and every control keep the ring's own meaning. The first card sits on
|
|
7
|
+
* the equator so a deck opens facing a card, not a pole.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sphereLatitude(index: number, count: number): number;
|
|
10
|
+
/** Where a card's face points after the CSS placement, with every angle in radians. */
|
|
11
|
+
export declare function sphereNormal(angle: number, latitude: number, tilt: number): [number, number, number];
|
|
12
|
+
/** Latitudes are written when the slides change, never per frame. */
|
|
13
|
+
export declare function createSphereAttachment(request: Omit<ShapeFitRequest, 'sphere'>): DeckAttachment;
|
|
14
|
+
/**
|
|
15
|
+
* The second axis of `drag-axis:both`: one host variable every slot reads, so a drag costs no per-card
|
|
16
|
+
* work. Bounded so the pole never tips past the camera and sideways drags keep their direction.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSpherePitch(ctx: PrepareContext, tiltParamDeg: number, arcDeg: number): {
|
|
19
|
+
value: () => number;
|
|
20
|
+
begin(): void;
|
|
21
|
+
/** `turns` is the drag as a fraction of a full cycle, the same law as the ring's own axis. */
|
|
22
|
+
move(turns: number): void;
|
|
23
|
+
};
|
|
@@ -65,7 +65,8 @@ export declare function stackPlace(offset: number, count: number): number;
|
|
|
65
65
|
* list), `opacity` and `filter` for the recession, `discrete` for the host's `display: grid` — the
|
|
66
66
|
* same reasoning `SPATIAL_RING_PRIMITIVE` gives for its own pair, widened by what a stack paints.
|
|
67
67
|
* `reducedMotion: 'shorten'` for the same reason as the ring: the deck must keep working, and the
|
|
68
|
-
* policy
|
|
68
|
+
* base.css policy shortens the marked host's slot transitions, while `deck.ts` starts any
|
|
69
|
+
* auto-motion paused.
|
|
69
70
|
*/
|
|
70
71
|
export declare const SPATIAL_STACK_PRIMITIVE: Primitive;
|
|
71
72
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Preset, Primitive } from '../../core/types.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type Registry } from '../../core/registry.js';
|
|
3
3
|
/**
|
|
4
4
|
* Feedback & status effects (catalog section K). Loading indicators default to `load` and
|
|
5
5
|
* `reducedMotion: 'disable'` — an infinite loop shortened to 1ms strobes rather than stopping,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SplitStage } from '../../core/registry.js';
|
|
2
|
+
import type { Reporter } from '../../core/reporter.js';
|
|
1
3
|
import type { Cleanup, EffectParams } from '../../core/types.js';
|
|
2
4
|
/**
|
|
3
5
|
* DOM-surgery helpers behind `slat-assemble` (catalog section G).
|
|
@@ -103,6 +105,14 @@ export interface SlatBuildOptions {
|
|
|
103
105
|
from: SlatFrom;
|
|
104
106
|
fold: boolean;
|
|
105
107
|
}
|
|
108
|
+
/** Each moving cell clips its own offset copy of the same full-size paint surface. */
|
|
109
|
+
export declare function installTileStage(host: Element, grid: {
|
|
110
|
+
hoists?: {
|
|
111
|
+
cols?: string;
|
|
112
|
+
};
|
|
113
|
+
rows?: string;
|
|
114
|
+
tileFit?: 'stretch';
|
|
115
|
+
}, reporter: Reporter): SplitStage | undefined;
|
|
106
116
|
export declare function installSlatStage(el: Element, doc: Document, win: Window, options: SlatBuildOptions): SlatStage | null;
|
|
107
117
|
/**
|
|
108
118
|
* Forward validated timing params onto the stage, so `media.css`'s `--kui-i * --kui-stagger`
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { ContinuousSetup } from '../../core/instances.js';
|
|
3
|
+
import type { Cleanup, EffectParams } from '../../core/types.js';
|
|
4
|
+
/** App-formatted LTR characters: O(n) matching, boundary reads only, no animation-frame loop. */
|
|
5
|
+
export declare function prepareNumberTokens(el: Element, params: EffectParams, ctx: PrepareContext): ContinuousSetup | Cleanup;
|
|
@@ -10,10 +10,9 @@ export interface CountLayers {
|
|
|
10
10
|
/** `aria-hidden` node the ticking display writes to on every frame. */
|
|
11
11
|
decorative: HTMLElement;
|
|
12
12
|
/**
|
|
13
|
-
* Visually-hidden twin
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* install, from the same `to`/`format` the tween itself will settle on.
|
|
13
|
+
* Visually-hidden twin holding the destination value, never intermediate animation frames.
|
|
14
|
+
* A live odometer writes it once per incoming value; a fixed counter writes it at install.
|
|
15
|
+
* The number is content, so it carries no aria-live announcement.
|
|
17
16
|
*/
|
|
18
17
|
srOnly: HTMLElement;
|
|
19
18
|
/**
|