summaryrefslogtreecommitdiff
path: root/apps/web/src/components/editor
diff options
context:
space:
mode:
authorAndrew Kordampalos <megakor@gmail.com>2025-06-23 22:32:17 +0300
committerAndrew Kordampalos <megakor@gmail.com>2025-06-23 22:32:17 +0300
commit267a590d04c89ad0a74b682d8b575197e1a742fc (patch)
tree410ace493293dbe4c3bc2e9c5c429871300be166 /apps/web/src/components/editor
parent2a1ac8fcf7075a4a25523c7601e98013313658c5 (diff)
downloadopencut-267a590d04c89ad0a74b682d8b575197e1a742fc.tar.gz
De-duplicate code
Diffstat (limited to 'apps/web/src/components/editor')
-rw-r--r--apps/web/src/components/editor/timeline.tsx22
1 files changed, 10 insertions, 12 deletions
diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx
index 24169b69..e2c212d9 100644
--- a/apps/web/src/components/editor/timeline.tsx
+++ b/apps/web/src/components/editor/timeline.tsx
@@ -290,18 +290,20 @@ export function Timeline() {
}
};
- // Deselect all clips when clicking empty timeline area and seek to clicked position
+ 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
- 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);
+ handleSeekToPosition(e);
}
};
@@ -500,11 +502,7 @@ export function Timeline() {
}}
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);
+ handleSeekToPosition(e);
}}
>
{/* Time markers */}