@bevelo/motion 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/index.cjs +6364 -0
- package/dist/index.d.cts +1832 -0
- package/dist/index.d.ts +1832 -0
- package/dist/index.js +6278 -0
- package/dist/live/flip.cjs +78 -0
- package/dist/live/flip.d.cts +21 -0
- package/dist/live/flip.d.ts +21 -0
- package/dist/live/flip.js +77 -0
- package/dist/live/presence.cjs +7 -0
- package/dist/live/presence.d.cts +2 -0
- package/dist/live/presence.d.ts +2 -0
- package/dist/live/presence.js +1 -0
- package/dist/live/spring-value.cjs +4 -0
- package/dist/live/spring-value.d.cts +41 -0
- package/dist/live/spring-value.d.ts +41 -0
- package/dist/live/spring-value.js +1 -0
- package/dist/presence-BadXSYGX.cjs +499 -0
- package/dist/presence-CbHtzolg.d.cts +126 -0
- package/dist/presence-CbHtzolg.d.ts +126 -0
- package/dist/presence-Dt789xG9.js +470 -0
- package/dist/spring-CfdnEGs4.d.cts +118 -0
- package/dist/spring-CfdnEGs4.d.ts +118 -0
- package/dist/spring-value-D7dvds3M.cjs +373 -0
- package/dist/spring-value-fKpX3pAG.js +338 -0
- package/dist/timeline.cjs +53 -0
- package/dist/timeline.d.cts +61 -0
- package/dist/timeline.d.ts +61 -0
- package/dist/timeline.js +52 -0
- package/package.json +63 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_spring_value = require("../spring-value-D7dvds3M.cjs");
|
|
3
|
+
let _bevelo_runtime = require("@bevelo/runtime");
|
|
4
|
+
// src/live/flip.ts
|
|
5
|
+
function inverseOf(move) {
|
|
6
|
+
const style = move.el.style;
|
|
7
|
+
if (style === void 0) return null;
|
|
8
|
+
const { from, to } = move;
|
|
9
|
+
return {
|
|
10
|
+
style,
|
|
11
|
+
dx: from.x - to.x,
|
|
12
|
+
dy: from.y - to.y,
|
|
13
|
+
sx: to.width > 0 ? from.width / to.width : 1,
|
|
14
|
+
sy: to.height > 0 ? from.height / to.height : 1,
|
|
15
|
+
transform: style.transform,
|
|
16
|
+
origin: style.transformOrigin
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Each move's inverse is painted in the first write pass; springs translate and scale to identity,
|
|
21
|
+
* then restores the inline transform and transform-origin each element had when `flip` was called.
|
|
22
|
+
*/
|
|
23
|
+
function flip(moves, options = {}) {
|
|
24
|
+
const inverses = moves.map(inverseOf).filter((inverse) => inverse !== null);
|
|
25
|
+
const first = moves[0];
|
|
26
|
+
if (inverses.length === 0 || first === void 0) return {
|
|
27
|
+
finished: Promise.resolve(),
|
|
28
|
+
cancel() {}
|
|
29
|
+
};
|
|
30
|
+
const frame = options.frame ?? (0, _bevelo_runtime.frameLoopOf)(first.el.ownerDocument);
|
|
31
|
+
let done = false;
|
|
32
|
+
let resolveFinished = () => {};
|
|
33
|
+
const finished = new Promise((resolve) => {
|
|
34
|
+
resolveFinished = resolve;
|
|
35
|
+
});
|
|
36
|
+
function restore() {
|
|
37
|
+
for (const inverse of inverses) {
|
|
38
|
+
inverse.style.transform = inverse.transform;
|
|
39
|
+
inverse.style.transformOrigin = inverse.origin;
|
|
40
|
+
}
|
|
41
|
+
resolveFinished();
|
|
42
|
+
}
|
|
43
|
+
const progress = require_spring_value.createSpringValue(0, {
|
|
44
|
+
frame,
|
|
45
|
+
spring: options.spring,
|
|
46
|
+
onUpdate(p) {
|
|
47
|
+
if (done) return;
|
|
48
|
+
if (p === 1 && progress.velocity === 0) {
|
|
49
|
+
done = true;
|
|
50
|
+
restore();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const rest = 1 - p;
|
|
54
|
+
for (const inverse of inverses) {
|
|
55
|
+
inverse.style.transformOrigin = "0 0";
|
|
56
|
+
inverse.style.transform = `translate(${inverse.dx * rest}px, ${inverse.dy * rest}px) scale(${1 + (inverse.sx - 1) * rest}, ${1 + (inverse.sy - 1) * rest})`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
progress.to(1);
|
|
61
|
+
return {
|
|
62
|
+
finished,
|
|
63
|
+
cancel() {
|
|
64
|
+
if (done) return;
|
|
65
|
+
done = true;
|
|
66
|
+
progress.stop();
|
|
67
|
+
const off = frame.job({
|
|
68
|
+
kind: "write",
|
|
69
|
+
name: "flip-cancel",
|
|
70
|
+
run() {
|
|
71
|
+
off();
|
|
72
|
+
restore();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.flip = flip;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { n as SpringConfig } from "../spring-CfdnEGs4.cjs";
|
|
2
|
+
import { FrameLoop, LayoutMove } from "@bevelo/runtime";
|
|
3
|
+
/** What {@link flip} accepts. */
|
|
4
|
+
export interface FlipOptions {
|
|
5
|
+
/** The spring the batch settles on. */
|
|
6
|
+
readonly spring?: SpringConfig | undefined;
|
|
7
|
+
/** The loop to run on. Defaults to the first element's document runtime frame. */
|
|
8
|
+
readonly frame?: FrameLoop | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** A running FLIP. */
|
|
11
|
+
export interface FlipRun {
|
|
12
|
+
/** Resolves once every element is back on its prior inline transform, after a settle or a cancel. */
|
|
13
|
+
readonly finished: Promise<void>;
|
|
14
|
+
/** Ends the run now; the prior inline transforms are restored in the next write pass. */
|
|
15
|
+
cancel(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Each move's inverse is painted in the first write pass; springs translate and scale to identity,
|
|
19
|
+
* then restores the inline transform and transform-origin each element had when `flip` was called.
|
|
20
|
+
*/
|
|
21
|
+
export declare function flip(moves: readonly LayoutMove[], options?: FlipOptions): FlipRun;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { n as SpringConfig } from "../spring-CfdnEGs4.js";
|
|
2
|
+
import { FrameLoop, LayoutMove } from "@bevelo/runtime";
|
|
3
|
+
/** What {@link flip} accepts. */
|
|
4
|
+
export interface FlipOptions {
|
|
5
|
+
/** The spring the batch settles on. */
|
|
6
|
+
readonly spring?: SpringConfig | undefined;
|
|
7
|
+
/** The loop to run on. Defaults to the first element's document runtime frame. */
|
|
8
|
+
readonly frame?: FrameLoop | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** A running FLIP. */
|
|
11
|
+
export interface FlipRun {
|
|
12
|
+
/** Resolves once every element is back on its prior inline transform, after a settle or a cancel. */
|
|
13
|
+
readonly finished: Promise<void>;
|
|
14
|
+
/** Ends the run now; the prior inline transforms are restored in the next write pass. */
|
|
15
|
+
cancel(): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Each move's inverse is painted in the first write pass; springs translate and scale to identity,
|
|
19
|
+
* then restores the inline transform and transform-origin each element had when `flip` was called.
|
|
20
|
+
*/
|
|
21
|
+
export declare function flip(moves: readonly LayoutMove[], options?: FlipOptions): FlipRun;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { t as createSpringValue } from "../spring-value-fKpX3pAG.js";
|
|
2
|
+
import { frameLoopOf } from "@bevelo/runtime";
|
|
3
|
+
// src/live/flip.ts
|
|
4
|
+
function inverseOf(move) {
|
|
5
|
+
const style = move.el.style;
|
|
6
|
+
if (style === void 0) return null;
|
|
7
|
+
const { from, to } = move;
|
|
8
|
+
return {
|
|
9
|
+
style,
|
|
10
|
+
dx: from.x - to.x,
|
|
11
|
+
dy: from.y - to.y,
|
|
12
|
+
sx: to.width > 0 ? from.width / to.width : 1,
|
|
13
|
+
sy: to.height > 0 ? from.height / to.height : 1,
|
|
14
|
+
transform: style.transform,
|
|
15
|
+
origin: style.transformOrigin
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Each move's inverse is painted in the first write pass; springs translate and scale to identity,
|
|
20
|
+
* then restores the inline transform and transform-origin each element had when `flip` was called.
|
|
21
|
+
*/
|
|
22
|
+
function flip(moves, options = {}) {
|
|
23
|
+
const inverses = moves.map(inverseOf).filter((inverse) => inverse !== null);
|
|
24
|
+
const first = moves[0];
|
|
25
|
+
if (inverses.length === 0 || first === void 0) return {
|
|
26
|
+
finished: Promise.resolve(),
|
|
27
|
+
cancel() {}
|
|
28
|
+
};
|
|
29
|
+
const frame = options.frame ?? frameLoopOf(first.el.ownerDocument);
|
|
30
|
+
let done = false;
|
|
31
|
+
let resolveFinished = () => {};
|
|
32
|
+
const finished = new Promise((resolve) => {
|
|
33
|
+
resolveFinished = resolve;
|
|
34
|
+
});
|
|
35
|
+
function restore() {
|
|
36
|
+
for (const inverse of inverses) {
|
|
37
|
+
inverse.style.transform = inverse.transform;
|
|
38
|
+
inverse.style.transformOrigin = inverse.origin;
|
|
39
|
+
}
|
|
40
|
+
resolveFinished();
|
|
41
|
+
}
|
|
42
|
+
const progress = createSpringValue(0, {
|
|
43
|
+
frame,
|
|
44
|
+
spring: options.spring,
|
|
45
|
+
onUpdate(p) {
|
|
46
|
+
if (done) return;
|
|
47
|
+
if (p === 1 && progress.velocity === 0) {
|
|
48
|
+
done = true;
|
|
49
|
+
restore();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const rest = 1 - p;
|
|
53
|
+
for (const inverse of inverses) {
|
|
54
|
+
inverse.style.transformOrigin = "0 0";
|
|
55
|
+
inverse.style.transform = `translate(${inverse.dx * rest}px, ${inverse.dy * rest}px) scale(${1 + (inverse.sx - 1) * rest}, ${1 + (inverse.sy - 1) * rest})`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
progress.to(1);
|
|
60
|
+
return {
|
|
61
|
+
finished,
|
|
62
|
+
cancel() {
|
|
63
|
+
if (done) return;
|
|
64
|
+
done = true;
|
|
65
|
+
progress.stop();
|
|
66
|
+
const off = frame.job({
|
|
67
|
+
kind: "write",
|
|
68
|
+
name: "flip-cancel",
|
|
69
|
+
run() {
|
|
70
|
+
off();
|
|
71
|
+
restore();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export { flip };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_presence = require("../presence-BadXSYGX.cjs");
|
|
3
|
+
exports.createPresence = require_presence.createPresence;
|
|
4
|
+
exports.createPresenceGroup = require_presence.createPresenceGroup;
|
|
5
|
+
exports.cssRunner = require_presence.cssRunner;
|
|
6
|
+
exports.presenceGroupStep = require_presence.presenceGroupStep;
|
|
7
|
+
exports.presenceStep = require_presence.presenceStep;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as presenceGroupStep, a as PresenceOptions, c as createPresence, d as PresenceEvent, f as PresenceGroupEntry, g as PresenceState, h as PresenceMode, i as PresenceGroupOptions, l as createPresenceGroup, m as PresenceGroupState, n as PresenceEntry, o as PresenceRunner, p as PresenceGroupEvent, r as PresenceGroup, s as PresenceSnapshot, t as Presence, u as cssRunner, v as presenceStep } from "../presence-CbHtzolg.cjs";
|
|
2
|
+
export { Presence, PresenceEntry, type PresenceEvent, PresenceGroup, type PresenceGroupEntry, type PresenceGroupEvent, PresenceGroupOptions, type PresenceGroupState, type PresenceMode, PresenceOptions, PresenceRunner, PresenceSnapshot, type PresenceState, createPresence, createPresenceGroup, cssRunner, presenceGroupStep, presenceStep };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as presenceGroupStep, a as PresenceOptions, c as createPresence, d as PresenceEvent, f as PresenceGroupEntry, g as PresenceState, h as PresenceMode, i as PresenceGroupOptions, l as createPresenceGroup, m as PresenceGroupState, n as PresenceEntry, o as PresenceRunner, p as PresenceGroupEvent, r as PresenceGroup, s as PresenceSnapshot, t as Presence, u as cssRunner, v as presenceStep } from "../presence-CbHtzolg.js";
|
|
2
|
+
export { Presence, PresenceEntry, type PresenceEvent, PresenceGroup, type PresenceGroupEntry, type PresenceGroupEvent, PresenceGroupOptions, type PresenceGroupState, type PresenceMode, PresenceOptions, PresenceRunner, PresenceSnapshot, type PresenceState, createPresence, createPresenceGroup, cssRunner, presenceGroupStep, presenceStep };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createPresence, n as createPresenceGroup, r as cssRunner, i as presenceGroupStep, a as presenceStep } from "../presence-Dt789xG9.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_spring_value = require("../spring-value-D7dvds3M.cjs");
|
|
3
|
+
exports.createSpringValue = require_spring_value.createSpringValue;
|
|
4
|
+
exports.springRunner = require_spring_value.springRunner;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as SpringConfig } from "../spring-CfdnEGs4.cjs";
|
|
2
|
+
import { o as PresenceRunner } from "../presence-CbHtzolg.cjs";
|
|
3
|
+
import { FrameLoop } from "@bevelo/runtime";
|
|
4
|
+
/** A number that springs to its targets. */
|
|
5
|
+
export interface SpringValue {
|
|
6
|
+
/** The value as of the last sampled frame, or the last `jump`. */
|
|
7
|
+
readonly value: number;
|
|
8
|
+
/** The rate of change as of the last sampled frame, in value units per second. */
|
|
9
|
+
readonly velocity: number;
|
|
10
|
+
/**
|
|
11
|
+
* Springs to `target` from the current value and velocity. Resolves true once at rest on
|
|
12
|
+
* `target`, false when a later `to`, `jump` or `stop` takes over first.
|
|
13
|
+
*/
|
|
14
|
+
to(target: number, spring?: SpringConfig): Promise<boolean>;
|
|
15
|
+
/** Sets the value with no motion; `onUpdate` sees it in the next write pass. */
|
|
16
|
+
jump(value: number): void;
|
|
17
|
+
/** Halts where the value is now. */
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
20
|
+
/** What {@link createSpringValue} needs. */
|
|
21
|
+
export interface SpringValueOptions {
|
|
22
|
+
/** Called in the write pass of each frame that changed the value. */
|
|
23
|
+
onUpdate(value: number): void;
|
|
24
|
+
/** The spring every `to` uses unless the call passes its own. Endpoints and velocity are ignored. */
|
|
25
|
+
readonly spring?: SpringConfig | undefined;
|
|
26
|
+
/** The loop to run on. Defaults to the document runtime's frame. */
|
|
27
|
+
readonly frame?: FrameLoop | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Samples the analytic solveSpring in the compute pass; onUpdate runs in the write pass. Retarget keeps velocity. */
|
|
30
|
+
export declare function createSpringValue(initial: number, options: SpringValueOptions): SpringValue;
|
|
31
|
+
/** What {@link springRunner} needs. */
|
|
32
|
+
export interface SpringRunnerOptions {
|
|
33
|
+
/** Writes a progress value onto the element, in the write pass. 0 is closed, 1 is open. */
|
|
34
|
+
write(el: Element, progress: number): void;
|
|
35
|
+
/** The spring both phases use. */
|
|
36
|
+
readonly spring?: SpringConfig | undefined;
|
|
37
|
+
/** The loop to run on. Defaults to the element's document runtime frame. */
|
|
38
|
+
readonly frame?: FrameLoop | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** progress 0 -> 1 on enter, 1 -> 0 on exit, through `write`. Reduced motion: jumps. */
|
|
41
|
+
export declare function springRunner(options: SpringRunnerOptions): PresenceRunner;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as SpringConfig } from "../spring-CfdnEGs4.js";
|
|
2
|
+
import { o as PresenceRunner } from "../presence-CbHtzolg.js";
|
|
3
|
+
import { FrameLoop } from "@bevelo/runtime";
|
|
4
|
+
/** A number that springs to its targets. */
|
|
5
|
+
export interface SpringValue {
|
|
6
|
+
/** The value as of the last sampled frame, or the last `jump`. */
|
|
7
|
+
readonly value: number;
|
|
8
|
+
/** The rate of change as of the last sampled frame, in value units per second. */
|
|
9
|
+
readonly velocity: number;
|
|
10
|
+
/**
|
|
11
|
+
* Springs to `target` from the current value and velocity. Resolves true once at rest on
|
|
12
|
+
* `target`, false when a later `to`, `jump` or `stop` takes over first.
|
|
13
|
+
*/
|
|
14
|
+
to(target: number, spring?: SpringConfig): Promise<boolean>;
|
|
15
|
+
/** Sets the value with no motion; `onUpdate` sees it in the next write pass. */
|
|
16
|
+
jump(value: number): void;
|
|
17
|
+
/** Halts where the value is now. */
|
|
18
|
+
stop(): void;
|
|
19
|
+
}
|
|
20
|
+
/** What {@link createSpringValue} needs. */
|
|
21
|
+
export interface SpringValueOptions {
|
|
22
|
+
/** Called in the write pass of each frame that changed the value. */
|
|
23
|
+
onUpdate(value: number): void;
|
|
24
|
+
/** The spring every `to` uses unless the call passes its own. Endpoints and velocity are ignored. */
|
|
25
|
+
readonly spring?: SpringConfig | undefined;
|
|
26
|
+
/** The loop to run on. Defaults to the document runtime's frame. */
|
|
27
|
+
readonly frame?: FrameLoop | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Samples the analytic solveSpring in the compute pass; onUpdate runs in the write pass. Retarget keeps velocity. */
|
|
30
|
+
export declare function createSpringValue(initial: number, options: SpringValueOptions): SpringValue;
|
|
31
|
+
/** What {@link springRunner} needs. */
|
|
32
|
+
export interface SpringRunnerOptions {
|
|
33
|
+
/** Writes a progress value onto the element, in the write pass. 0 is closed, 1 is open. */
|
|
34
|
+
write(el: Element, progress: number): void;
|
|
35
|
+
/** The spring both phases use. */
|
|
36
|
+
readonly spring?: SpringConfig | undefined;
|
|
37
|
+
/** The loop to run on. Defaults to the element's document runtime frame. */
|
|
38
|
+
readonly frame?: FrameLoop | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** progress 0 -> 1 on enter, 1 -> 0 on exit, through `write`. Reduced motion: jumps. */
|
|
41
|
+
export declare function springRunner(options: SpringRunnerOptions): PresenceRunner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createSpringValue, n as springRunner } from "../spring-value-fKpX3pAG.js";
|