diff --git a/src/components/TrimControl.tsx b/src/components/TrimControl.tsx index 5df0ab46..7521f12f 100644 --- a/src/components/TrimControl.tsx +++ b/src/components/TrimControl.tsx @@ -2,6 +2,8 @@ import { EditRecipe } from "@/lib/types"; +const MIN_CLIP_DURATION = 0.1; + interface Props { recipe: EditRecipe; onChange: (patch: Partial) => void; @@ -13,14 +15,14 @@ export default function TrimControl({ recipe, onChange, duration }: Props) { const n = parseFloat(val); if (isNaN(n) || n < 0) return; if (duration > 0 && n >= duration) return; - if (recipe.trimEnd !== null && n >= recipe.trimEnd) return; + if (recipe.trimEnd !== null && n >= recipe.trimEnd - MIN_CLIP_DURATION) return; onChange({ trimStart: n }); }; const handleEnd = (val: string) => { if (val === "") { onChange({ trimEnd: null }); return; } const n = parseFloat(val); - if (isNaN(n) || n <= 0 || n <= recipe.trimStart) return; + if (isNaN(n) || n <= 0 || n <= recipe.trimStart + MIN_CLIP_DURATION) return; if (duration > 0 && n > duration) return; onChange({ trimEnd: n }); }; @@ -67,6 +69,12 @@ export default function TrimControl({ recipe, onChange, duration }: Props) { Duration: {duration.toFixed(1)}s

)} + {recipe.trimEnd !== null && + recipe.trimEnd - recipe.trimStart < MIN_CLIP_DURATION && ( +

+ Clip must be at least 0.1 seconds long. +

+ )} ); }