From 0c305e42ea6a36a6f7fc14fd4377d03197a831cf Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Jun 2026 10:10:55 -0400 Subject: [PATCH] feat: smooth horizontal + vertical scroll on jump/link follow! gains an optional smooth flag. The jump/link path (goto! with follow?) now glides both axes; playback-follow stays instant (smooth would fight the per-frame updates) and scrubbing doesn't scroll at all, so clicking stays snappy. Co-Authored-By: Claude Opus 4.8 --- tl/src/tl/views.cljs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tl/src/tl/views.cljs b/tl/src/tl/views.cljs index 7efd112..4254c0d 100644 --- a/tl/src/tl/views.cljs +++ b/tl/src/tl/views.cljs @@ -68,10 +68,14 @@ (when (and @video-el source-frame) (set! (.-currentTime @video-el) (/ source-frame fps)))) -(defn- follow! [fps zoom playhead] - (when-let [el @scroll-el] - (let [x (px playhead fps zoom)] - (set! (.-scrollLeft el) (max 0 (- x (/ (.-clientWidth el) 2))))))) +(defn- follow! + ([fps zoom playhead] (follow! fps zoom playhead false)) + ([fps zoom playhead smooth?] + (when-let [el @scroll-el] + (let [left (max 0 (- (px playhead fps zoom) (/ (.-clientWidth el) 2)))] + (if smooth? + (.scrollTo el #js {:left left :behavior "smooth"}) + (set! (.-scrollLeft el) left)))))) ;; The playhead is a single full-height overlay on `.timeline` (spanning the ;; pinned annotation lanes AND the scrolling tracks as one line) rather than a @@ -204,7 +208,7 @@ (seek-video! fps (scene/local->source segs local)) (when @play (swap! play assoc :idx (seg-at segs local))) ; keep playback in sync (when follow? - (r/after-render #(do (follow! fps zoom local) + (r/after-render #(do (follow! fps zoom local true) ; smooth on jump/link (scroll-to-seg-track! segs local))))))) (defn video-monitor []