Skip to content

Follow seeks (scrub-while-paused) and add pauseAutoscroll/resumeAutoscroll#223

Open
maboa wants to merge 1 commit into
mainfrom
222-follow-seeks-pause-hook
Open

Follow seeks (scrub-while-paused) and add pauseAutoscroll/resumeAutoscroll#223
maboa wants to merge 1 commit into
mainfrom
222-follow-seeks-pause-hook

Conversation

@maboa

@maboa maboa commented Jun 21, 2026

Copy link
Copy Markdown
Member

Resolves the core + pause-hook parts of #222. The scrollContainer constructor option is deferred to #217 (options-object refactor) where it belongs without further bloating the positional signature.

Changes

Core — follow seeks

BasePlayer.attachEventListeners now attaches a seeked listener that calls a new HyperaudioLite.handleSeeked() method. On every seek (including while paused) the transcript's read/unread visual state and scroll position re-align to the new playhead. The word-level .active class is not toggled here — that suppression-while-paused behaviour is tracked separately in #220.

This means scrubbing the media (drag the seek bar, jump in the native controls, set currentTime programmatically) now updates the transcript out of the box. Downstream consumers like the Hyperaudio Lite Editor that currently glue this themselves can drop their reimplementation.

The non-DOM player adapters (SoundCloud, YouTube, Vimeo, VideoJS) override attachEventListeners, so they're unaffected by this change. Adding seek-follow to each of those would be a sensible follow-up.

Pause hook

Two thin documented helpers:

player.pauseAutoscroll();   // e.g. while a user edits the transcript
player.resumeAutoscroll();

These wrap the existing instance.autoscroll boolean — no behaviour change, just a supported API instead of poking the field.

scrollContainer (deferred)

Adding scrollContainer as an 8th positional constructor argument would push the signature further into "boolean parameter trap" territory. Better landed alongside the options-object refactor in #217 — added a note there.

Compat

  • Seeked listener: technically a behaviour change (scrub-while-paused now updates transcript instead of doing nothing), but the previous behaviour was the gap the issue is about. Consumers with their own glue will run twice harmlessly until they remove it.
  • Pause/resume helpers: pure addition, zero risk.

Test plan

  • npm test — all 25 Jest tests pass
  • Manual: native <video> example — scrub while paused, confirm transcript scroll + read/unread state follow
  • Manual: native <video> example — pauseAutoscroll() from console, scrub, confirm no scroll; resumeAutoscroll(), confirm scroll resumes

Resolves #222 (core + pause hook).

Core change: BasePlayer now attaches a 'seeked' listener that calls a
new HyperaudioLite.handleSeeked() method, updating transcript visual
state and scroll position whenever the media is scrubbed — including
while paused. The non-DOM player adapters (SoundCloud, YouTube, Vimeo,
VideoJS) override attachEventListeners so they're unaffected by this
change; adding seek-follow there is a follow-up.

Pause hook: pauseAutoscroll() / resumeAutoscroll() document the
supported way to temporarily disable autoscroll (e.g. while a user
edits the transcript), replacing the unsupported pattern of poking
instance.autoscroll directly.

scrollContainer constructor option deferred to #217 (options-object
refactor) where it belongs.
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