Skip to content

🎥 Make videos programmatically with React

slider decimal bug fix

Patric Salvisberg14d641f484c0
diff --git a/packages/cli/src/editor/components/NewComposition/InputDragger.tsx b/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
index fc2bf8e815..c975b75a8f 100644
--- a/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
+++ b/packages/cli/src/editor/components/NewComposition/InputDragger.tsx
@@ -24,7 +24,6 @@ export const InputDragger: React.FC<Props> = ({
}) => {
const [inputFallback, setInputFallback] = useState(false);
const fallbackRef = useRef<HTMLInputElement>(null);
-
const style = useMemo(() => {
return {
...inputBaseStyle,
@@ -70,6 +69,11 @@ export const InputDragger: React.FC<Props> = ({
[]
);
+ const roundToStep = (val: number, stepSize: number) => {
+ const factor = 1 / stepSize;
+ return Math.ceil(val * factor) / factor;
+ };
+
const onPointerDown: PointerEventHandler = useCallback(
(e) => {
const {pageX, pageY} = e;
@@ -81,6 +85,7 @@ export const InputDragger: React.FC<Props> = ({
const step = Number(_step ?? 1);
const min = Number(_min ?? 0);
const max = Number(_max ?? Infinity);
+
if (distanceFromStart > 4) {
setClickLock(true);
}
@@ -90,12 +95,9 @@ export const InputDragger: React.FC<Props> = ({
[-5, -4, 0, 4, 5],
[-step, 0, 0, 0, step]
);
- const newValue = Math.min(
- max,
- Math.max(min, Math.floor(Number(value) + diff))
- );
- const roundToStep = Math.floor(newValue / step) * step;
- onValueChange(roundToStep);
+ const newValue = Math.min(max, Math.max(min, Number(value) + diff));
+ const roundedToStep = roundToStep(newValue, step);
+ onValueChange(roundedToStep);
};
window.addEventListener('mousemove', moveListener);
@@ -112,7 +114,7 @@ export const InputDragger: React.FC<Props> = ({
}
);
},
- [_step, _min, value, onValueChange]
+ [_step, _min, _max, value, onValueChange]
);
useEffect(() => {
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
index 07e47d6a19..5560542135 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
@@ -333,14 +333,14 @@ export const RenderModal: React.FC<{
const onScaleChanged: ChangeEventHandler<HTMLInputElement> = useCallback(
(e) => {
setScale((q) => {
- const newQuality = parseFloat(e.target.value);
- if (Number.isNaN(newQuality)) {
+ const newScale = parseFloat(e.target.value);
+ if (Number.isNaN(newScale)) {
return q;
}
const newScaleClamped = Math.min(
MAX_SCALE,
- Math.max(newQuality, MIN_SCALE)
+ Math.max(newScale, MIN_SCALE)
);
return newScaleClamped;
});
@@ -562,7 +562,7 @@ export const RenderModal: React.FC<{
// TODO: Cannot click and type in 0.2
onValueChange={onScaleSetDirectly}
name="scale"
- step={0.05}
+ step={0.1}
min={MIN_SCALE}
max={MAX_SCALE}
/>
@@ -663,7 +663,7 @@ export const RenderModal: React.FC<{
// TODO: Cannot click and type in 0.2
onValueChange={onScaleSetDirectly}
name="scale"
- step={0.05}
+ step={0.1}
min={MIN_SCALE}
max={MAX_SCALE}
/>
diff --git a/packages/cli/src/preview-server/render-queue/process-still.ts b/packages/cli/src/preview-server/render-queue/process-still.ts
index 8471467b54..c012601dc0 100644
--- a/packages/cli/src/preview-server/render-queue/process-still.ts
+++ b/packages/cli/src/preview-server/render-queue/process-still.ts
@@ -69,6 +69,5 @@ export const processStill = async ({
addCleanupCallback,
cancelSignal: job.cancelToken.cancelSignal,
});
- // TODO: Cancel signal does not work
// TODO: Accept CLI options
};