diff options
| author | iza <59828082+izadoesdev@users.noreply.github.com> | 2025-06-24 08:00:20 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-24 08:00:20 +0300 |
| commit | 973ee68ae285ae55c07ede266b44b514c1a0f7d8 (patch) | |
| tree | 04b6fc53b0cb624b9a43176d04ae3a55b1fa164d /apps/web/src/components | |
| parent | 55c95cd5748a250b9afd48062811990a7106e7a6 (diff) | |
| parent | c7f56d61d776f87607fc02e9f71bb4b8e1a49d98 (diff) | |
| download | opencut-973ee68ae285ae55c07ede266b44b514c1a0f7d8.tar.gz | |
Merge pull request #25 from andrewckor/playhead-browse
Implement click-to-seek functionality in timeline
Diffstat (limited to 'apps/web/src/components')
| -rw-r--r-- | apps/web/src/components/editor/timeline.tsx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx index 9af7a204..db810d30 100644 --- a/apps/web/src/components/editor/timeline.tsx +++ b/apps/web/src/components/editor/timeline.tsx @@ -290,11 +290,21 @@ export function Timeline() { }
};
- // Deselect all clips when clicking empty timeline area
+ const handleSeekToPosition = (e: React.MouseEvent) => {
+ 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);
+ };
+
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
+ handleSeekToPosition(e);
}
};
@@ -487,10 +497,14 @@ 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
+ handleSeekToPosition(e);
+ }}
>
{/* Time markers */}
{(() => {
|
