diff options
| author | Andrew Kordampalos <megakor@gmail.com> | 2025-06-23 22:17:36 +0300 |
|---|---|---|
| committer | Andrew Kordampalos <megakor@gmail.com> | 2025-06-23 22:17:36 +0300 |
| commit | 2a1ac8fcf7075a4a25523c7601e98013313658c5 (patch) | |
| tree | f26efdf67b49ade8cff2133e6f9286bda9f9c1b4 /apps/web/src | |
| parent | fddbecc736a037b938385eb5eb7d1ec752581c76 (diff) | |
| download | opencut-2a1ac8fcf7075a4a25523c7601e98013313658c5.tar.gz | |
Implement click-to-seek functionality in timeline
Diffstat (limited to 'apps/web/src')
| -rw-r--r-- | apps/web/src/app/editor/editor.css | 4 | ||||
| -rw-r--r-- | apps/web/src/app/editor/page.tsx | 1 | ||||
| -rw-r--r-- | apps/web/src/components/editor/timeline.tsx | 19 |
3 files changed, 22 insertions, 2 deletions
diff --git a/apps/web/src/app/editor/editor.css b/apps/web/src/app/editor/editor.css new file mode 100644 index 00000000..f482c6de --- /dev/null +++ b/apps/web/src/app/editor/editor.css @@ -0,0 +1,4 @@ +/* Prevent scroll jumping on Mac devices when using the editor */ +body { + overflow: hidden; +}
\ No newline at end of file diff --git a/apps/web/src/app/editor/page.tsx b/apps/web/src/app/editor/page.tsx index 64186a3e..2efb59cc 100644 --- a/apps/web/src/app/editor/page.tsx +++ b/apps/web/src/app/editor/page.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect } from "react"; +import "./editor.css"; import { ResizablePanelGroup, ResizablePanel, diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 675b398c..24169b69 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -290,11 +290,18 @@ export function Timeline() { }
};
- // Deselect all clips when clicking empty timeline area
+ // Deselect all clips when clicking empty timeline area and seek to clicked position
const handleTimelineAreaClick = (e: React.MouseEvent) => {
// Only clear selection if the click target is the timeline background (not a child/clip)
if (e.target === e.currentTarget) {
clearSelectedClips();
+
+ // Calculate the clicked time position and seek to it
+ const rect = e.currentTarget.getBoundingClientRect();
+ const clickX = e.clientX - rect.left;
+ const clickedTime = clickX / (50 * zoomLevel);
+ const clampedTime = Math.max(0, Math.min(duration, clickedTime));
+ seek(clampedTime);
}
};
@@ -487,10 +494,18 @@ export function Timeline() { <div className="flex-1 relative overflow-hidden">
<ScrollArea className="w-full">
<div
- className="relative h-12 bg-muted/30"
+ className="relative h-12 bg-muted/30 cursor-pointer"
style={{
width: `${Math.max(1000, duration * 50 * zoomLevel)}px`,
}}
+ onClick={(e) => {
+ // Calculate the clicked time position and seek to it
+ const rect = e.currentTarget.getBoundingClientRect();
+ const clickX = e.clientX - rect.left;
+ const clickedTime = clickX / (50 * zoomLevel);
+ const clampedTime = Math.max(0, Math.min(duration, clickedTime));
+ seek(clampedTime);
+ }}
>
{/* Time markers */}
{(() => {
|
