♻️ refactor: refactor zoom focus handling in video editor settings and playback

This commit is contained in:
xKeCo
2026-04-01 02:38:42 -05:00
parent 3be195cc15
commit 163b12d6fc
2 changed files with 18 additions and 4 deletions
@@ -52,6 +52,7 @@ import type {
PlaybackSpeed,
WebcamLayoutPreset,
ZoomDepth,
ZoomFocusMode,
} from "./types";
import { SPEED_OPTIONS } from "./types";
@@ -92,8 +93,8 @@ interface SettingsPanelProps {
onWallpaperChange: (path: string) => void;
selectedZoomDepth?: ZoomDepth | null;
onZoomDepthChange?: (depth: ZoomDepth) => void;
selectedZoomFocusMode?: import("./types").ZoomFocusMode | null;
onZoomFocusModeChange?: (mode: import("./types").ZoomFocusMode) => void;
selectedZoomFocusMode?: ZoomFocusMode | null;
onZoomFocusModeChange?: (mode: ZoomFocusMode) => void;
hasCursorTelemetry?: boolean;
selectedZoomId?: string | null;
onZoomDelete?: (id: string) => void;
@@ -199,8 +199,21 @@ function getConnectedRegionTransition(
const currentScale = ZOOM_DEPTH_SCALES[currentRegion.depth];
const nextScale = ZOOM_DEPTH_SCALES[nextRegion.depth];
const transitionScale = lerp(currentScale, nextScale, transitionProgress);
const currentFocus = getResolvedFocus(currentRegion, currentScale, timeMs, cursorTelemetry);
const nextFocus = getResolvedFocus(nextRegion, nextScale, timeMs, cursorTelemetry);
// Both regions share the same timeMs, so interpolate cursor once and reuse.
const sharedCursorFocus =
cursorTelemetry && cursorTelemetry.length > 0
? interpolateCursorAt(cursorTelemetry, timeMs)
: null;
const currentFocus = clampFocusToScale(
currentRegion.focusMode === "auto" && sharedCursorFocus
? sharedCursorFocus
: currentRegion.focus,
currentScale,
);
const nextFocus = clampFocusToScale(
nextRegion.focusMode === "auto" && sharedCursorFocus ? sharedCursorFocus : nextRegion.focus,
nextScale,
);
const transitionFocus = getLinearFocus(currentFocus, nextFocus, transitionProgress);
return {