From 52c700b8434594b28228e8a9ef357c31a60c7def Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 30 Jun 2026 14:06:20 -0400 Subject: [PATCH] fix: scroll timeline to deep-linked playhead on first load When a project opens with a ?f= query parameter, the playhead position is now visible in the timeline view. Previously, the playhead was positioned correctly in the UI but the timeline didn't scroll to show it. This triggered scroll-to-seg-track on first render when playhead > 0 and segments are loaded. Co-Authored-By: Claude Haiku 4.5 --- tl/src/tl/views.cljs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tl/src/tl/views.cljs b/tl/src/tl/views.cljs index 60b9ccc..380a7f8 100644 --- a/tl/src/tl/views.cljs +++ b/tl/src/tl/views.cljs @@ -15,6 +15,7 @@ (defonce body-scroll-el (atom nil)) ; the vertical (tracks) scroll container (defonce playhead-el (atom nil)) ; the single full-height playhead overlay (defonce played-bar (atom nil)) ; [ann-id bar-idx] last auto-scrolled to during playback +(defonce scrolled-on-load? (atom nil)) ; did we scroll to deep-linked playhead on load (defonce play (atom nil)) ; {:ctx :segs :fps :idx} while playing, else nil (defonce active-insert! (atom nil)) ; the live content-editor's (insert! link) fn (declare commit-link!) @@ -342,6 +343,10 @@ (r/after-render (fn [] (follow! fps zoom playhead) + ;; first load: if playhead was deep-linked (from query param), scroll to it once + (when (and (nil? @scrolled-on-load?) (> playhead 0) (seq segs)) + (reset! scrolled-on-load? true) + (scroll-to-seg-track! segs playhead)) ;; clip-following: only while the playhead is actually inside a bar of ;; an annotation that opts in (:meta :scroll-to) — scroll each of its ;; clips into view as the playhead crosses onto a new bar (discontinuity). @@ -356,7 +361,8 @@ (when (not= current-bar @played-bar) (reset! played-bar current-bar) (scroll-to-seg-track! segs playhead))))) - (reset! played-bar nil)) + (do (reset! played-bar nil) + (reset! scrolled-on-load? nil))) (r/after-render #(position-playhead! fps zoom playhead)) [:div.timeline {:class (when-not @tracks-open? "tracks-collapsed")} [:div.playhead.timeline-playhead {:ref (fn [n] (reset! playhead-el n))}