Merge pull request #25 from andrewckor/playhead-browse
Implement click-to-seek functionality in timeline
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,3 +19,6 @@
|
|||||||
# typescript
|
# typescript
|
||||||
/apps/web/next-env.d.ts
|
/apps/web/next-env.d.ts
|
||||||
/apps/web/yarn.lock
|
/apps/web/yarn.lock
|
||||||
|
|
||||||
|
# asdf version management
|
||||||
|
.tool-versions
|
||||||
|
4
apps/web/src/app/editor/editor.css
Normal file
4
apps/web/src/app/editor/editor.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/* Prevent scroll jumping on Mac devices when using the editor */
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
import "./editor.css";
|
||||||
import {
|
import {
|
||||||
ResizablePanelGroup,
|
ResizablePanelGroup,
|
||||||
ResizablePanel,
|
ResizablePanel,
|
||||||
|
@ -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) => {
|
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) {
|
if (e.target === e.currentTarget) {
|
||||||
clearSelectedClips();
|
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">
|
<div className="flex-1 relative overflow-hidden">
|
||||||
<ScrollArea className="w-full">
|
<ScrollArea className="w-full">
|
||||||
<div
|
<div
|
||||||
className="relative h-12 bg-muted/30"
|
className="relative h-12 bg-muted/30 cursor-pointer"
|
||||||
style={{
|
style={{
|
||||||
width: `${Math.max(1000, duration * 50 * zoomLevel)}px`,
|
width: `${Math.max(1000, duration * 50 * zoomLevel)}px`,
|
||||||
}}
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
|
// Calculate the clicked time position and seek to it
|
||||||
|
handleSeekToPosition(e);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{/* Time markers */}
|
{/* Time markers */}
|
||||||
{(() => {
|
{(() => {
|
||||||
|
Reference in New Issue
Block a user