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 <noreply@anthropic.com>
This commit is contained in:
parent
967ca97e84
commit
0c305e42ea
1 changed files with 9 additions and 5 deletions
|
|
@ -68,10 +68,14 @@
|
|||
(when (and @video-el source-frame)
|
||||
(set! (.-currentTime @video-el) (/ source-frame fps))))
|
||||
|
||||
(defn- follow! [fps zoom playhead]
|
||||
(defn- follow!
|
||||
([fps zoom playhead] (follow! fps zoom playhead false))
|
||||
([fps zoom playhead smooth?]
|
||||
(when-let [el @scroll-el]
|
||||
(let [x (px playhead fps zoom)]
|
||||
(set! (.-scrollLeft el) (max 0 (- x (/ (.-clientWidth el) 2)))))))
|
||||
(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 []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue