summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaran Singh <karansingh5112002@gmail.com>2025-06-27 00:50:37 +0530
committerKaran Singh <karansingh5112002@gmail.com>2025-06-27 00:50:37 +0530
commitf3c45ee8925f1fa25684a19f7e054cec5742ef76 (patch)
tree3e3eb56b8d39f2bc16de11338d08bd2d82e25bd6
parent17ef81007495ccf6c02c77c77815b7413d9d127a (diff)
downloadopencut-f3c45ee8925f1fa25684a19f7e054cec5742ef76.tar.gz
refactor: Update playhead auto-scroll buffer and remove conflicting sync
-rw-r--r--apps/web/src/components/editor/timeline.tsx12
1 files changed, 4 insertions, 8 deletions
diff --git a/apps/web/src/components/editor/timeline.tsx b/apps/web/src/components/editor/timeline.tsx
index 46aaf13f..2d60102a 100644
--- a/apps/web/src/components/editor/timeline.tsx
+++ b/apps/web/src/components/editor/timeline.tsx
@@ -611,7 +611,7 @@ export function Timeline() {
rulerViewport.removeEventListener('scroll', handleRulerScroll);
tracksViewport.removeEventListener('scroll', handleTracksScroll);
};
- }, [duration, zoomLevel]);
+ }, []);
// --- Playhead auto-scroll effect ---
useEffect(() => {
@@ -622,21 +622,17 @@ export function Timeline() {
const viewportWidth = rulerViewport.clientWidth;
const scrollMin = 0;
const scrollMax = rulerViewport.scrollWidth - viewportWidth;
- // Center the playhead if it's not visible (60px buffer)
+ // Center the playhead if it's not visible (100px buffer)
const desiredScroll = Math.max(
scrollMin,
Math.min(scrollMax, playheadPx - viewportWidth / 2)
);
if (
- playheadPx < rulerViewport.scrollLeft + 60 ||
- playheadPx > rulerViewport.scrollLeft + viewportWidth - 60
+ playheadPx < rulerViewport.scrollLeft + 100 ||
+ playheadPx > rulerViewport.scrollLeft + viewportWidth - 100
) {
rulerViewport.scrollLeft = tracksViewport.scrollLeft = desiredScroll;
}
- // Keep both scrolls in sync
- if (rulerViewport.scrollLeft !== tracksViewport.scrollLeft) {
- rulerViewport.scrollLeft = tracksViewport.scrollLeft = Math.max(rulerViewport.scrollLeft, tracksViewport.scrollLeft);
- }
}, [playheadPosition, duration, zoomLevel]);
return (