fix: read live video.currentTime for rapid frame steps and add JSDoc

- Read currentTime directly from the video element instead of the React
  ref so rapid arrow key presses each advance by exactly one frame
- Add JSDoc docstrings to frameStep.ts exports
This commit is contained in:
theaiagent
2026-04-03 22:44:25 +03:00
parent cd0f2ab318
commit 3bfcd8576b
2 changed files with 12 additions and 3 deletions
+7 -3
View File
@@ -949,13 +949,17 @@ export default function VideoEditor() {
return;
}
e.preventDefault();
const video = videoPlaybackRef.current?.video;
if (!video) {
return;
}
const direction = e.key === "ArrowLeft" ? "backward" : "forward";
const newTime = computeFrameStepTime(
currentTimeRef.current,
durationRef.current,
video.currentTime,
Number.isFinite(video.duration) ? video.duration : durationRef.current,
direction,
);
handleSeek(newTime);
video.currentTime = newTime;
return;
}
+5
View File
@@ -1,5 +1,10 @@
/** Duration of a single frame in seconds at 60 FPS (~16.67ms). */
export const FRAME_DURATION_SEC = 1 / 60;
/**
* Compute the new playhead time after stepping one frame forward or backward.
* The result is clamped to the range [0, duration].
*/
export function computeFrameStepTime(
currentTime: number,
duration: number,