8000 feat(editor): timeline auto-pages to keep playhead on screen by johannboehme · Pull Request #6 · johannboehme/tk-1 · GitHub
[go: up one dir, main page]

Skip to content

feat(editor): timeline auto-pages to keep playhead on screen - #6

Merged
johannboehme merged 1 commit into
mainfrom
claude/musing-mahavira-3934ba
May 1, 2026
Merged

johannboehme merged 1 commit into
mainfrom
claude/musing-mahavira-3934ba

Conversation

@johannboehme
Copy link
Copy Markdown
Owner

Summary

When the timeline is zoomed in and playback advances past the right edge of the visible region, the playhead currently disappears off-screen until the user manually scrolls. This change makes the timeline page instead — scrollX snaps so the playhead reappears at the left edge of the next "screen" the moment it exits the visible range.

  • Single useEffect in Timeline.tsx watching currentTime against the existing viewStart / viewEnd derived in render
  • Instant (no animation) — at high zoom the page-flip fires often and any easing would lag the playhead behind itself
  • Gated on the playhead having actually moved this render via a useRef, so manual scrolling while paused is preserved rather than snapping back to the playhead
  • Works for both Cuts and P-FX program-strip modes (they share the same scrollX / zoom state)

Why

Watching playback at zoom ≥ 4 was unusable: the playhead would slide off the right edge within a few seconds and the user had to hand-scroll just to see where they were. Standard NLE behavior is "follow playhead during playback, paging at the boundary"; this brings the editor in line with that.

Notes for reviewers

  • During playback, scrolling away will be re-paged on the next RAF tick — intentional, matches standard NLE follow-playhead semantics. To inspect a far-away clip mid-playback, pause first.
  • The moved ref is what keeps paused-state manual scrolls from being undone. Without it, the effect would fire when only the view changed (user scroll) and snap back to the stationary playhead.
  • Programmatic seeks (e.g. dragging the playhead grip to a far position, loop wrap) auto-page too, which is desirable.
  • No isPlaying gate — the moved ref subsumes its job and lets manual seeks page correctly.

Test plan

  • Load a project with audio ≥ 30 s, zoom in (zoom ≈ 8), press play → playhead reaches right edge → timeline snaps so playhead is at the left of the next page; repeats every few seconds
  • Crank zoom to 32 → page-flips fire more frequently, no visual lag or animation
  • Pause, scroll manually with trackpad / mini-map → scroll stays put, does NOT snap back to the playhead
  • Paused, seek playhead far off-screen → view snaps to a page containing the new playhead
  • Enable playback.loop and let it wrap → view pages backward to follow the wrap
  • Play to the very end of the timeline → last page renders full (clamped at maxScroll); playhead glides to the right edge instead of paging past the end
  • Verify in both Cuts and P-FX program-strip modes (shared scroll, one check is enough)

🤖 Generated with Claude Code

…layback

When zoomed in, the playhead used to run off the visible region and the
user lost sight of where playback was. The timeline now snaps scrollX so
the playhead reappears at the left edge of the next "screen" the moment
it exits the visible range. Instant (no animation), since at high zoom
the page-flip fires often.

Gated on the playhead having actually moved this render — manual
scrolling while paused is preserved instead of snapping back to the
playhead. During playback, scrolling away will be re-paged on the next
frame (matches standard NLE follow-playhead behavior).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@johannboehme
johannboehme merged commit a9159f3 into main May 1, 2026
1 check passed
@johannboehme
johannboehme deleted the claude/musing-mahavira-3934ba branch May 1, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0