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 []