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))}