From 1c6154999d7806fe9b2f1991fece18e20f5205b2 Mon Sep 17 00:00:00 2001 From: SamSyntax Date: Mon, 23 Jun 2025 21:30:17 +0200 Subject: [PATCH] Adding comments --- apps/web/src/components/editor/timeline.tsx | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 83ff590..9af7a20 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -557,25 +557,25 @@ export function Timeline() { {/* Playhead in ruler */}
{ e.preventDefault(); e.stopPropagation(); const handleMouseMove = (e: MouseEvent) => { - const timeline = timelineRef.current; - if (!timeline) return; - const rect = timeline.getBoundingClientRect(); - const mouseX = Math.max(0, e.clientX - rect.left); - const newTime = mouseX / (50 * zoomLevel); - seek(newTime); + const timeline = timelineRef.current; // Get timeline element ref to track the position + if (!timeline) return; // If no timeline element, exit + const rect = timeline.getBoundingClientRect(); // Get the bounding rect of the timeline element + const mouseX = Math.max(0, e.clientX - rect.left); // Calculate the mouse position relative to the timeline element + const newTime = mouseX / (50 * zoomLevel); // Calculate the time based on the mouse position + seek(newTime); // Set the current time }; const handleMouseUp = () => { - window.removeEventListener("mousemove", handleMouseMove); - window.removeEventListener("mouseup", handleMouseUp); + window.removeEventListener("mousemove", handleMouseMove); // Remove the mousemove event listener + window.removeEventListener("mouseup", handleMouseUp); // Remove the mouseup event listener }; - window.addEventListener("mousemove", handleMouseMove); - window.addEventListener("mouseup", handleMouseUp); + window.addEventListener("mousemove", handleMouseMove); // Add the mousemove event listener + window.addEventListener("mouseup", handleMouseUp); // Add the mouseup event listener }} >