Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

TL7d: a clip's own In and Out animations (CapCut's Animation tab): Clip.enter and Clip.exit (a kind and its frames), set and taken off by the set operation, never longer than the clip, each kept by its own half when split; in a composition the sequence's <Transition> edge. sdk/video edges.ts holds the kinds and their styles with no React (transitionAt, transitionStyle, edgesStyle), which <Transition> now draws from and sdk/timeline's animStyle previews a film's clip by; CODE_KINDS is its TRANSITION_KINDS. Four tests

shinyobjectza393b366ac7e
diff --git a/sdk/timeline/src/anim.ts b/sdk/timeline/src/anim.ts
new file mode 100644
index 00000000..2c475c91
--- /dev/null
+++ b/sdk/timeline/src/anim.ts
@@ -0,0 +1,16 @@
+// A clip's own In and Out animations as the picture shows them (docs/timeline.feature TL7d): the edges a
+// composition's <Transition> draws (sdk/video edges.ts), so the timeline's preview of a film matches the render.
+import { edgesStyle, type EdgeStyle, TRANSITION_KINDS, type TransitionKind } from "@raea/video/edges"
+import type { Anim, Clip, Frames } from "./model"
+
+export type { EdgeStyle } from "@raea/video/edges"
+
+/** raea's own kind, or a fade for a plugin's, which only its own code draws. */
+const kindOf = (k: string): TransitionKind => (TRANSITION_KINDS.includes(k as TransitionKind) ? (k as TransitionKind) : "fade")
+
+/** The clip's style `into` frames from its start, coming in by its In and going out by its Out, each over no more
+ * of it than it has. Empty when neither plays there. */
+export function animStyle(c: Clip, into: Frames): EdgeStyle {
+ const edge = (a?: Anim) => (a ? { kind: kindOf(a.kind), frames: Math.min(a.length, c.length) } : undefined)
+ return edgesStyle(edge(c.enter), edge(c.exit), into, c.length)
+}
diff --git a/sdk/timeline/src/index.ts b/sdk/timeline/src/index.ts
index cc42beba..41a0d7b4 100644
--- a/sdk/timeline/src/index.ts
+++ b/sdk/timeline/src/index.ts
@@ -10,3 +10,4 @@ export * from "./cache"
export * from "./registry"
export * from "./play"
export * from "./captions"
+export * from "./anim"
diff --git a/sdk/timeline/src/model.ts b/sdk/timeline/src/model.ts
index 1a042aa4..7eb037d1 100644
--- a/sdk/timeline/src/model.ts
+++ b/sdk/timeline/src/model.ts
@@ -46,6 +46,14 @@ export interface Marker {
color?: string
}
+/** How a clip comes in or goes out on its own (TL7d): a transition's kind over its own first or last frames. */
+export interface Anim {
+ /** fade, slide, wipe, zoom or a plugin's (TRANSITIONS) */
+ kind: string
+ /** how many of the clip's frames it takes */
+ length: Frames
+}
+
/** A span of something on a track: footage, a sound, words, a composition's sequence, an effect. */
export interface Clip {
/** its own id, unique on the timeline */
@@ -90,6 +98,10 @@ export interface Clip {
fadeIn?: Frames
/** sound: how long it fades out to its end */
fadeOut?: Frames
+ /** the picture or words: how it comes in over its first frames (TL7d, CapCut's In animation) */
+ enter?: Anim
+ /** the picture or words: how it goes out over its last frames (TL7d, CapCut's Out animation) */
+ exit?: Anim
/** its element in the code (file:line:col, docs/editing.feature E2) */
at?: string
/** markers on the clip itself, in frames from its start (TL2e) */
diff --git a/sdk/timeline/src/ops.ts b/sdk/timeline/src/ops.ts
index 81f751fe..27a24315 100644
--- a/sdk/timeline/src/ops.ts
+++ b/sdk/timeline/src/ops.ts
@@ -3,7 +3,7 @@
// After each one the timeline is settled: the main track closed while its magnet is on (TL4a), what sits over a
// main clip carried with it while linkage is on (TL4c), transitions kept only on cuts that still exist.
import { cut as cutKeys, sorted } from "./keys"
-import { type Clip, end, find, type Frames, type Key, type Marker, slot, speedOf, type SpeedPoint, type Timeline, type Track, type TrackKind, type Transition, type Value, type Ease } from "./model"
+import { type Anim, type Clip, end, find, type Frames, type Key, type Marker, slot, speedOf, type SpeedPoint, type Timeline, type Track, type TrackKind, type Transition, type Value, type Ease } from "./model"
import { fits } from "./snap"
import { played } from "./speed"
import type { TextStyle } from "./registry"
@@ -34,7 +34,7 @@ export type Op =
/** a still of the frame under `at` on a clip (the main track's, when none is named), `length` frames long, put in
* there: the clip is split and the still goes between its halves (TL3h) */
| { op: "freeze"; at: Frames; length: Frames; id?: string }
- | { op: "set"; id: string; set: Partial<Pick<Clip, "name" | "off" | "volume" | "fadeIn" | "fadeOut" | "speed" | "group" | "reverse">> & { curve?: SpeedPoint[] | null; props?: Record<string, Value | boolean> } }
+ | { op: "set"; id: string; set: Partial<Pick<Clip, "name" | "off" | "volume" | "fadeIn" | "fadeOut" | "speed" | "group" | "reverse">> & { curve?: SpeedPoint[] | null; props?: Record<string, Value | boolean>; /** its In or Out animation (TL7d); null takes it off */ enter?: Anim | null; exit?: Anim | null } }
/** a property's key at a frame of its clip: made, or its value (and ease) changed (TL5a) */
| { op: "key"; id: string; prop: string; at: Frames; value: Value; ease?: Ease }
| { op: "unkey"; id: string; prop: string; at: Frames }
@@ -264,7 +264,7 @@ function run(t: Timeline, op: Exclude<Op, { op: "restore" }>): Timeline {
}
case "set": {
const { clip } = open(t, op.id)
- const { props, curve, ...rest } = op.set
+ const { props, curve, enter, exit, ...rest } = op.set
let c: Clip = { ...clip, ...rest, ...(props && { props: { ...clip.props, ...props } }) }
const source = shown(clip)
if (curve !== undefined || (rest.speed !== undefined && rest.speed !== clip.speed)) {
@@ -273,6 +273,13 @@ function run(t: Timeline, op: Exclude<Op, { op: "restore" }>): Timeline {
// the same frames of source, at the new pace
c = { ...c, curve: points, shows: points ? source : undefined, length: Math.max(1, whole(points ? played(points, source) : source / speedOf(c))) }
}
+ // an In or Out animation (TL7d): a kind, over no more of the clip than it has; null takes it off
+ for (const [side, a] of [["enter", enter], ["exit", exit]] as const) {
+ if (a === undefined) continue
+ if (a !== null && (typeof a.kind !== "string" || !a.kind || !(a.length >= 1))) no("an animation is a kind and at least one frame")
+ const { [side]: _, ...without } = c
+ c = a ? { ...without, [side]: { kind: a.kind, length: Math.min(whole(a.length), c.length) } } : without
+ }
return change(t, clip.id, () => c)
}
case "key":
@@ -353,7 +360,7 @@ function shiftKeys(keys: Record<string, Key[]>, d: Frames): Record<string, Key[]
}
/** A clip as its two parts either side of timeline frame `at`: the left keeps its id, the right takes `id`. Media
- * keep their place in the source, keys stay at their frames, each fade stays on its own end. */
+ * keep their place in the source, keys stay at their frames, each fade and each In or Out animation stays on its own end. */
function halves(c: Clip, at: Frames, id: string): [Clip, Clip] {
const d = at - c.start
const parts = Object.entries(c.keys ?? {}).map(([p, ks]) => [p, cutKeys(ks, d)] as const)
@@ -362,8 +369,8 @@ function halves(c: Clip, at: Frames, id: string): [Clip, Clip] {
return Object.keys(ks).length ? ks : undefined
}
const share = (len: number) => (c.shows === undefined ? {} : { shows: (c.shows * len) / c.length })
- const left: Clip = { ...c, ...share(d), length: d, fadeOut: undefined, keys: keysOf(0), markers: c.markers?.filter((m) => m.at < d) }
- const right: Clip = { ...c, ...share(c.length - d), id, start: at, length: c.length - d, fadeIn: undefined, keys: keysOf(1), markers: c.markers?.filter((m) => m.at >= d).map((m) => ({ ...m, at: m.at - d })), ...(c.in !== undefined && { in: c.in + Math.round(d * speedOf(c)) }) }
+ const left: Clip = { ...c, ...share(d), length: d, fadeOut: undefined, exit: undefined, keys: keysOf(0), markers: c.markers?.filter((m) => m.at < d) }
+ const right: Clip = { ...c, ...share(c.length - d), id, start: at, length: c.length - d, fadeIn: undefined, enter: undefined, keys: keysOf(1), markers: c.markers?.filter((m) => m.at >= d).map((m) => ({ ...m, at: m.at - d })), ...(c.in !== undefined && { in: c.in + Math.round(d * speedOf(c)) }) }
return [left, right]
}
diff --git a/sdk/timeline/src/read.ts b/sdk/timeline/src/read.ts
index 02b0576b..c3fd7dd1 100644
--- a/sdk/timeline/src/read.ts
+++ b/sdk/timeline/src/read.ts
@@ -5,6 +5,7 @@
import { type Clip, type Ease, empty, end, find, type Frames, type Key, type Timeline, type Track } from "./model"
import { apply, type Op } from "./ops"
import { EFFECTS, type EffectPart, type TextStyle, textStyleError } from "./registry"
+import { TRANSITION_KINDS } from "@raea/video/edges"
/** A text clip's style, kept in its props as JSON: read back when it is well formed. */
export function textStyleOf(v: unknown): TextStyle | undefined {
@@ -128,8 +129,8 @@ export type SeqEdit =
* track's clips either side of it, so it is drawn under what is over them), else after the composition's last */
| { op: "media"; at: number; frames: number; kind: "video" | "image" | "audio"; file: string; after?: number; before?: number }
-/** The transitions a composition's <Transition> draws (sdk/video transition.tsx). */
-export const CODE_KINDS = ["fade", "slide", "wipe", "zoom"]
+/** The transitions a composition's <Transition> draws (sdk/video edges.ts). */
+export const CODE_KINDS: string[] = TRANSITION_KINDS
/** The properties a sequence's <Nudge> can key (sdk/video nudge.tsx). */
export const KEYED = ["x", "y", "scale", "rotate", "opacity"]
@@ -293,6 +294,22 @@ export function seqEdits(t: Timeline, op: Op): SeqEdit[] | { why: string } {
const look: SeqLook = { ...Object.fromEntries(KEYED.flatMap((k) => (num(k) === undefined ? [] : [[k, num(k)]]))), ...(p.mirror === true && { mirror: true }), ...(crop.some((v) => v > 0) && { crop }) }
return each([op.id], (r) => ({ op: "nudge", i: r.i, look }))
}
+ // its In and Out animations (TL7d): its <Transition>'s edges, as a cut's transition writes them
+ if (only.length && only.every((k) => k === "enter" || k === "exit")) {
+ const after = apply(t, op)
+ if (!after.ok) return { why: after.why }
+ const now = find(after.timeline, op.id)?.clip
+ const out: SeqEdit[] = []
+ for (const [key, side] of [["enter", "in"], ["exit", "out"]] as const) {
+ if (!only.includes(key)) continue
+ const a = now?.[key]
+ if (a && !CODE_KINDS.includes(a.kind)) return { why: `a composition draws ${CODE_KINDS.join(", ")}: "${a.kind}" isn't one its <Transition> has` }
+ const r = row(op.id)
+ if (!r) return { why: "only a composition's sequence comes in or goes out here" }
+ out.push({ op: "edge", i: r.i, side, kind: a?.kind ?? "fade", frames: a?.length ?? 0 })
+ }
+ return out
+ }
// a text clip's name is its words
if (only.length === 1 && only[0] === "name") {
if (find(t, op.id)?.clip.kind !== "text") return { why: "a sequence's name is its own code's: only a text clip's words change here" }
diff --git a/sdk/timeline/test/anim.test.ts b/sdk/timeline/test/anim.test.ts
new file mode 100644
index 00000000..f90f59e0
--- /dev/null
+++ b/sdk/timeline/test/anim.test.ts
@@ -0,0 +1,52 @@
+import { describe, expect, test } from "bun:test"
+import { animStyle, apply, type Clip, empty, find, seqEdits, type Timeline } from "../src"
+
+const film = (): Timeline => ({
+ ...empty(30),
+ tracks: [{ id: "main", kind: "main", clips: [{ id: "a", kind: "video", start: 0, length: 60, in: 0, source: 300 }, { id: "b", kind: "video", start: 60, length: 60, in: 60, source: 300 }] }],
+})
+const done = (t: Timeline, ...ops: Parameters<typeof apply>[1][]) =>
+ ops.reduce((x, op) => {
+ const r = apply(x, op)
+ if (!r.ok) throw new Error(r.why)
+ return r.timeline
+ }, t)
+const clip = (t: Timeline, id: string) => find(t, id)!.clip
+
+describe("TL7d: a clip's own In and Out animations", () => {
+ test("set on a clip, never longer than it, and taken off with null", () => {
+ const t = done(film(), { op: "set", id: "a", set: { enter: { kind: "zoom", length: 15 }, exit: { kind: "slide", length: 500 } } })
+ expect(clip(t, "a").enter).toEqual({ kind: "zoom", length: 15 })
+ expect(clip(t, "a").exit).toEqual({ kind: "slide", length: 60 })
+ const off = done(t, { op: "set", id: "a", set: { enter: null } })
+ expect("enter" in clip(off, "a")).toBe(false)
+ expect(clip(off, "a").exit).toEqual({ kind: "slide", length: 60 })
+ expect(apply(t, { op: "set", id: "a", set: { enter: { kind: "", length: 10 } } })).toEqual({ ok: false, why: "an animation is a kind and at least one frame" })
+ expect(apply(t, { op: "set", id: "a", set: { enter: { kind: "fade", length: 0 } } })).toEqual({ ok: false, why: "an animation is a kind and at least one frame" })
+ })
+
+ test("split, the first part keeps the In and the second the Out", () => {
+ const t = done(film(), { op: "set", id: "a", set: { enter: { kind: "fade", length: 10 }, exit: { kind: "wipe", length: 10 } } }, { op: "split", at: 30, ids: ["a"] })
+ expect([clip(t, "a").enter, clip(t, "a").exit]).toEqual([{ kind: "fade", length: 10 }, undefined])
+ expect([clip(t, "a+").enter, clip(t, "a+").exit]).toEqual([undefined, { kind: "wipe", length: 10 }])
+ })
+
+ test("the picture's style over its first and last frames, as <Transition> draws it", () => {
+ const c: Clip = { id: "a", kind: "video", start: 0, length: 60, enter: { kind: "fade", length: 10 }, exit: { kind: "zoom", length: 20 } }
+ expect(animStyle(c, 4)).toEqual({ opacity: 0.5 })
+ expect(animStyle(c, 30)).toEqual({})
+ // into its Out: halfway through a zoom, scaled and faded
+ const out = animStyle(c, 50)
+ expect(out.opacity).toBeCloseTo(0.75)
+ expect(Number(/^scale\(([\d.]+)\)$/.exec(out.transform ?? "")?.[1])).toBeCloseTo(0.9625)
+ // a plugin's kind shows as a fade
+ expect(animStyle({ ...c, enter: { kind: "glitch", length: 10 }, exit: undefined }, 4)).toEqual({ opacity: 0.5 })
+ })
+
+ test("in a composition each is its sequence's <Transition> edge, taken off with no frames", () => {
+ const t: Timeline = { ...empty(30), tracks: [{ id: "main", kind: "main", clips: [{ id: "seq-0", kind: "sequence", start: 0, length: 60 }] }] }
+ expect(seqEdits(t, { op: "set", id: "seq-0", set: { enter: { kind: "slide", length: 12 } } })).toEqual([{ op: "edge", i: 0, side: "in", kind: "slide", frames: 12 }])
+ expect(seqEdits(t, { op: "set", id: "seq-0", set: { exit: null } })).toEqual([{ op: "edge", i: 0, side: "out", kind: "fade", frames: 0 }])
+ expect(seqEdits(t, { op: "set", id: "seq-0", set: { enter: { kind: "glitch", length: 12 } } })).toEqual({ why: 'a composition draws fade, slide, wipe, zoom: "glitch" isn\'t one its <Transition> has' })
+ })
+})
diff --git a/sdk/video/package.json b/sdk/video/package.json
index 7281abbd..62ea54fd 100644
--- a/sdk/video/package.json
+++ b/sdk/video/package.json
@@ -16,6 +16,7 @@
"./nudge": "./src/nudge.tsx",
"./speed": "./src/speed.ts",
"./transition": "./src/transition.tsx",
+ "./edges": "./src/edges.ts",
"./words": "./src/words.tsx",
"./region": "./src/region.tsx",
"./overlay": "./src/overlay.tsx",
diff --git a/sdk/video/src/edges.ts b/sdk/video/src/edges.ts
new file mode 100644
index 00000000..29f317c0
--- /dev/null
+++ b/sdk/video/src/edges.ts
@@ -0,0 +1,54 @@
+// How a part comes in and goes out, as data and style with no React (docs/timeline.feature TL7a, TL7d): one table,
+// so <Transition> in a composition and the timeline's preview of a clip's In and Out on a film draw the same thing.
+
+/** fade: through black. slide: in from the right, out to the left. wipe: uncovered from the left, covered from the
+ * left. zoom: grows in from 85%, shrinks out to 85%, fading. A dissolve between two parts that only touch has no
+ * frames of the other to mix with, so it is written as a fade. */
+export type TransitionKind = "fade" | "slide" | "wipe" | "zoom";
+export const TRANSITION_KINDS: TransitionKind[] = ["fade", "slide", "wipe", "zoom"];
+
+export interface TransitionEdge {
+ /** which transition: fade, slide, wipe or zoom */
+ kind: TransitionKind;
+ /** how many of the part's frames it takes */
+ frames: number;
+}
+
+/** What an edge does to the part at a frame: a move, a fade and a cut-away, as CSS writes them. */
+export interface EdgeStyle {
+ /** a move or a scale */
+ transform?: string;
+ /** how much of it shows, 0 to 1 */
+ opacity?: number;
+ /** how much of it is covered */
+ clipPath?: string;
+}
+
+/** How far a part is into view: 0 not at all, 1 fully. `frame` is the part's own, `duration` its length. */
+export function transitionAt(edge: TransitionEdge | undefined, side: "in" | "out", frame: number, duration: number): number {
+ if (!edge || !(edge.frames > 0)) return 1;
+ const p = side === "in" ? (frame + 1) / edge.frames : (duration - frame) / edge.frames;
+ return Math.min(1, Math.max(0, p));
+}
+
+/** The style a kind gives at `p` (0 out of view, 1 in view), on the side it plays. */
+export function transitionStyle(kind: TransitionKind, side: "in" | "out", p: number): EdgeStyle {
+ if (p >= 1) return {};
+ // eased out, so it settles
+ const e = 1 - (1 - p) * (1 - p);
+ if (kind === "slide") return { transform: `translateX(${(side === "in" ? 1 - e : e - 1) * 100}%)` };
+ if (kind === "wipe") return { clipPath: side === "in" ? `inset(0 ${(1 - e) * 100}% 0 0)` : `inset(0 0 0 ${(1 - e) * 100}%)` };
+ if (kind === "zoom") return { transform: `scale(${0.85 + 0.15 * e})`, opacity: e };
+ return { opacity: p };
+}
+
+/** A part's style at its own `frame` of `duration`, coming in by `enter` and going out by `exit`: both at once (a part
+ * shorter than its two edges) puts the moves side by side and multiplies the fades. Empty when neither plays. */
+export function edgesStyle(enter: TransitionEdge | undefined, exit: TransitionEdge | undefined, frame: number, duration: number): EdgeStyle {
+ const a = enter ? transitionStyle(enter.kind, "in", transitionAt(enter, "in", frame, duration)) : {};
+ const b = exit ? transitionStyle(exit.kind, "out", transitionAt(exit, "out", frame, duration)) : {};
+ const transform = [a.transform, b.transform].filter(Boolean).join(" ") || undefined;
+ const opacity = a.opacity === undefined && b.opacity === undefined ? undefined : Number(a.opacity ?? 1) * Number(b.opacity ?? 1);
+ const clipPath = a.clipPath ?? b.clipPath;
+ return { ...(transform ? { transform } : {}), ...(opacity !== undefined ? { opacity } : {}), ...(clipPath ? { clipPath } : {}) };
+}
diff --git a/sdk/video/src/transition.tsx b/sdk/video/src/transition.tsx
index d5258aac..f0959884 100644
--- a/sdk/video/src/transition.tsx
+++ b/sdk/video/src/transition.tsx
@@ -1,23 +1,14 @@
// Transition: how a part comes in and goes out (docs/timeline.feature TL7a). The timeline writes a transition on a
// cut as one <Transition> around what each of the two parts holds: `out` on the part before the cut, `in` on the
-// part after it. It plays inside the part's own time (its <Sequence>'s first frames for `in`, its last for `out`),
-// so nothing outside the two parts changes and the film is as long as it was.
-import type { CSSProperties, ReactNode } from "react";
+// part after it, and a clip's own In and Out animation the same way (TL7d). It plays inside the part's own time (its
+// <Sequence>'s first frames for `in`, its last for `out`), so nothing outside the two parts changes and the film is
+// as long as it was. The kinds and their styles are edges.ts, which the timeline's preview draws with too.
+import type { ReactNode } from "react";
import { useLocalTime } from "@raea/app/clock";
+import { edgesStyle, TRANSITION_KINDS, type TransitionEdge } from "./edges";
import { AbsoluteFill } from "./timeline";
-/** fade: through black. slide: in from the right, out to the left. wipe: uncovered from the left, covered from the
- * left. zoom: grows in from 85%, shrinks out to 85%, fading. A dissolve between two parts that only touch has no
- * frames of the other to mix with, so it is written as a fade. */
-export type TransitionKind = "fade" | "slide" | "wipe" | "zoom";
-export const TRANSITION_KINDS: TransitionKind[] = ["fade", "slide", "wipe", "zoom"];
-
-export interface TransitionEdge {
- /** which transition: fade, slide, wipe or zoom */
- kind: TransitionKind;
- /** how many of the part's frames it takes */
- frames: number;
-}
+export { edgesStyle, type EdgeStyle, TRANSITION_KINDS, transitionAt, type TransitionEdge, type TransitionKind, transitionStyle } from "./edges";
export interface TransitionProps {
/** over the part's first frames */
@@ -28,24 +19,6 @@ export interface TransitionProps {
children?: ReactNode;
}
-/** How far a part is into view: 0 not at all, 1 fully. `frame` is the part's own, `duration` its length. */
-export function transitionAt(edge: TransitionEdge | undefined, side: "in" | "out", frame: number, duration: number): number {
- if (!edge || !(edge.frames > 0)) return 1;
- const p = side === "in" ? (frame + 1) / edge.frames : (duration - frame) / edge.frames;
- return Math.min(1, Math.max(0, p));
-}
-
-/** The style a kind gives at `p` (0 out of view, 1 in view), on the side it plays. */
-export function transitionStyle(kind: TransitionKind, side: "in" | "out", p: number): CSSProperties {
- if (p >= 1) return {};
- // eased out, so it settles
- const e = 1 - (1 - p) * (1 - p);
- if (kind === "slide") return { transform: `translateX(${(side === "in" ? 1 - e : e - 1) * 100}%)` };
- if (kind === "wipe") return { clipPath: side === "in" ? `inset(0 ${(1 - e) * 100}% 0 0)` : `inset(0 0 0 ${(1 - e) * 100}%)` };
- if (kind === "zoom") return { transform: `scale(${0.85 + 0.15 * e})`, opacity: e };
- return { opacity: p };
-}
-
/** Its children, coming in over the part's first frames and going out over its last. */
export function Transition({ in: enter, out: exit, children }: TransitionProps) {
const t = useLocalTime("Transition");
@@ -54,12 +27,7 @@ export function Transition({ in: enter, out: exit, children }: TransitionProps)
if (!TRANSITION_KINDS.includes(edge.kind)) throw new RangeError(`Transition: ${side}.kind is one of ${TRANSITION_KINDS.join(", ")}, got ${String(edge.kind)}`);
if (!Number.isFinite(edge.frames) || edge.frames < 0) throw new RangeError(`Transition: ${side}.frames must be 0 or more, got ${edge.frames}`);
}
- const a = enter ? transitionStyle(enter.kind, "in", transitionAt(enter, "in", t.frame, t.duration)) : {};
- const b = exit ? transitionStyle(exit.kind, "out", transitionAt(exit, "out", t.frame, t.duration)) : {};
- // both at once (a part shorter than its two transitions): the moves side by side, the fades multiplied
- const transform = [a.transform, b.transform].filter(Boolean).join(" ") || undefined;
- const opacity = a.opacity === undefined && b.opacity === undefined ? undefined : Number(a.opacity ?? 1) * Number(b.opacity ?? 1);
- const clipPath = a.clipPath ?? b.clipPath;
- if (!transform && opacity === undefined && !clipPath) return <>{children}</>;
- return <AbsoluteFill style={{ ...(transform ? { transform } : {}), ...(opacity !== undefined ? { opacity } : {}), ...(clipPath ? { clipPath } : {}) }}>{children}</AbsoluteFill>;
+ const style = edgesStyle(enter, exit, t.frame, t.duration);
+ if (!style.transform && style.opacity === undefined && !style.clipPath) return <>{children}</>;
+ return <AbsoluteFill style={style}>{children}</AbsoluteFill>;
}