Skip to content

Commit fae66c0

Browse files
committed
Add custom speed up
1 parent 390394c commit fae66c0

File tree

2 files changed

+77
-22
lines changed

2 files changed

+77
-22
lines changed

apps/desktop/src/routes/editor/ConfigSidebar.tsx

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,23 +1940,78 @@ function ClipSegmentConfig(props: {
19401940
</div>
19411941
<Field name="Speed" icon={<IconLucideFastForward class="size-4" />}>
19421942
<div class="flex flex-col gap-2">
1943-
<Slider
1944-
value={[props.segment.timescale]}
1945-
onChange={(v) =>
1946-
setProject(
1947-
"timeline",
1948-
"segments",
1949-
props.segmentIndex,
1950-
"timescale",
1951-
v[0]
1952-
)
1953-
}
1954-
minValue={0.25}
1955-
maxValue={4}
1956-
step={0.25}
1957-
formatTooltip={(v) => `${v}x`}
1958-
/>
1943+
<div class="flex gap-2 items-center">
1944+
<Slider
1945+
value={[props.segment.timescale]}
1946+
onChange={(v) =>
1947+
setProject(
1948+
"timeline",
1949+
"segments",
1950+
props.segmentIndex,
1951+
"timescale",
1952+
v[0]
1953+
)
1954+
}
1955+
minValue={0.1}
1956+
maxValue={10}
1957+
step={0.01}
1958+
formatTooltip={(v) => `${v.toFixed(2)}x`}
1959+
class="flex-1"
1960+
/>
1961+
<div class="flex items-center gap-1">
1962+
<TextInput
1963+
type="number"
1964+
value={props.segment.timescale.toFixed(2)}
1965+
onInput={(e) => {
1966+
const value = parseFloat(e.currentTarget.value);
1967+
if (!isNaN(value) && value > 0 && value <= 10) {
1968+
setProject(
1969+
"timeline",
1970+
"segments",
1971+
props.segmentIndex,
1972+
"timescale",
1973+
value
1974+
);
1975+
}
1976+
}}
1977+
onBlur={(e) => {
1978+
const value = parseFloat(e.currentTarget.value);
1979+
if (isNaN(value) || value <= 0) {
1980+
e.currentTarget.value = props.segment.timescale.toFixed(2);
1981+
} else if (value > 10) {
1982+
setProject(
1983+
"timeline",
1984+
"segments",
1985+
props.segmentIndex,
1986+
"timescale",
1987+
10
1988+
);
1989+
e.currentTarget.value = "10.00";
1990+
}
1991+
}}
1992+
class="w-16 px-2 py-1 text-xs text-center border rounded-md bg-gray-2 text-gray-12"
1993+
min="0.01"
1994+
max="10"
1995+
step="0.01"
1996+
/>
1997+
<span class="text-xs text-gray-11">x</span>
1998+
</div>
1999+
</div>
19592000
<div class="flex gap-2 text-xs">
2001+
<button
2002+
onClick={() =>
2003+
setProject(
2004+
"timeline",
2005+
"segments",
2006+
props.segmentIndex,
2007+
"timescale",
2008+
0.25
2009+
)
2010+
}
2011+
class="px-2 py-1 rounded-md bg-gray-3 hover:bg-gray-4 transition-colors"
2012+
>
2013+
0.25x
2014+
</button>
19602015
<button
19612016
onClick={() =>
19622017
setProject(
@@ -1992,12 +2047,12 @@ function ClipSegmentConfig(props: {
19922047
"segments",
19932048
props.segmentIndex,
19942049
"timescale",
1995-
1.5
2050+
2
19962051
)
19972052
}
19982053
class="px-2 py-1 rounded-md bg-gray-3 hover:bg-gray-4 transition-colors"
19992054
>
2000-
1.5x
2055+
2x
20012056
</button>
20022057
<button
20032058
onClick={() =>
@@ -2006,12 +2061,12 @@ function ClipSegmentConfig(props: {
20062061
"segments",
20072062
props.segmentIndex,
20082063
"timescale",
2009-
2
2064+
4
20102065
)
20112066
}
20122067
class="px-2 py-1 rounded-md bg-gray-3 hover:bg-gray-4 transition-colors"
20132068
>
2014-
2x
2069+
4x
20152070
</button>
20162071
</div>
20172072
</div>

apps/desktop/src/routes/editor/ui.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export function Slider(
123123
? typeof props.formatTooltip === "string"
124124
? `${props.value[0].toFixed(1)}${props.formatTooltip}`
125125
: props.formatTooltip
126-
? props.formatTooltip(props.value[0])
127-
: props.value[0].toFixed(1)
126+
? props.formatTooltip(props.value[0])
127+
: props.value[0].toFixed(1)
128128
: undefined
129129
}
130130
>

0 commit comments

Comments
 (0)