fix: scroll timeline to deep-linked playhead on first load
When a project opens with a ?f=<frame> 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 <noreply@anthropic.com>
This commit is contained in:
parent
d91ea6c78a
commit
52c700b843
1 changed files with 7 additions and 1 deletions
|
|
@ -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))}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue