TraceAvatar
Menu

Docs

Options and events

Every option, event and controller method.

createTrace options

OptionDefault
trace—a trace object, or the URL of a .trace.json
rootdocumentwhere elements are looked up
avatartrace’s{ name, image, color } override
controlsfalsea small play/pause/step/speed/restart bar
autoplayfalse
rate10.25–4
loopfalse
captions'bubble''bubble', 'bar' or 'none'
takeover'pause'what real viewer input does while playing: 'pause' or 'ignore'
keyboardfalseSpace/K play-pause, ←/→ steps (outside form fields)
scroll'auto'may a step scroll the page to its element? 'auto': yes, until the viewer scrolls the page; then not until they next play, pause or step. 'always', or 'never' for a guide embedded in a page people read on. (Next release.)
reducedMotion'auto'follows prefers-reduced-motion
seedtrace’schanges the shape of authored paths
navigate—(path) => void: go to a page the trace needs
currentPathlocation.pathnamewhere the viewer is, for apps that route without the address bar
mode'overlay''perform' acts on the page
prepare / onReset / resumeKey—see Do it for me; prepare and resumeKey work in overlay mode too
locators—your own element finders, tried first: (target, root, step) => Element | null

Events

Listen with on(name, fn):

EventWhen
stepa step starts ({ index, element })
stalleda step can’t find its element, or a wait times out ({ index, reason })
pagethe guide needs another page ({ index, want, at })
handoffDo it for me hands a masked field to the viewer
blockedprepare said not yet
stateplaying, paused and so on
endthe guide finished
errorsomething went wrong, such as a trace that couldn’t load

The controller

play(), pause(), toggle(), stop(), seek(ms), next(), prev(), setRate(r), on(event, fn), destroy(), and the read-only state, index, time, duration, trace and ready.

The full reference is in the README on GitHub.