Open source CapCut alternative.
TypeScript
refactor(site): the max clip fade is one shared rule [rebuild]
David Leb015a049a1c8
diff --git a/site/src/cut/components/Inspector.tsx b/site/src/cut/components/Inspector.tsxindex cec3fabb..7a380924 100644--- a/site/src/cut/components/Inspector.tsx+++ b/site/src/cut/components/Inspector.tsx@@ -66,7 +66,7 @@ import {type OverlayLoopStyle,type WordEffectId,} from "@donkeycut/effects-kit";-import { clipWindow, useEditor, type EditorState } from "@/cut/lib/store";+import { clipWindow, maxClipFade, useEditor, type EditorState } from "@/cut/lib/store";import { usePanelView } from "@/cut/lib/panelViews";import { usePreviewTime } from "@/cut/lib/playhead";import { CLIP_MAX_ZOOM, clipCovers, clipKeyed, clipPoseAt, clipZoom, contentRect } from "@/cut/lib/types";@@ -1428,8 +1428,7 @@ function AudioPanel({ clip }: { clip: AudioClip }) {// Detached audio can carry a playback rate; its timeline length is (out-in)/speed.const speed = clip.speed && clip.speed > 0 ? clip.speed : 1;const len = (clip.out - clip.in) / speed;- // A fade can take at most half the clip so in+out never overlap.- const maxFade = Math.max(0.1, Math.round((len / 2) * 10) / 10);+ const maxFade = maxClipFade(clip);// Commit closes the checkpoint setAudio opened (or opens+closes one for a// typed entry), so any adjustment lands as a single undo step.const commitAudio = (patch: Partial<AudioClip>) => {diff --git a/site/src/cut/lib/store.ts b/site/src/cut/lib/store.tsindex 21284ab3..427371fd 100644--- a/site/src/cut/lib/store.ts+++ b/site/src/cut/lib/store.ts@@ -5039,6 +5039,12 @@ export function clipLen(c: VideoClip | AudioClip) {return Math.max(MIN_LEN, eff);}+/** The longest fade a clip takes: half its footprint, so a fade in and a+ * fade out never overlap. Tenths of a second, like the controls that set it. */+export function maxClipFade(c: VideoClip | AudioClip) {+ return Math.max(0.1, Math.round((clipLen(c) / 2) * 10) / 10);+}+/** How closely two starts/ends must agree to count as the same cut. */const TOUCH_EPS = 0.02;