Docs
Options and events
Every option, event and controller method.
createTrace options
| Option | Default | |
|---|---|---|
trace | — | a trace object, or the URL of a .trace.json |
root | document | where elements are looked up |
avatar | trace’s | { name, image, color } override |
controls | false | a small play/pause/step/speed/restart bar |
autoplay | false | |
rate | 1 | 0.25–4 |
loop | false | |
captions | 'bubble' | 'bubble', 'bar' or 'none' |
takeover | 'pause' | what real viewer input does while playing: 'pause' or 'ignore' |
keyboard | false | Space/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 |
seed | trace’s | changes the shape of authored paths |
navigate | — | (path) => void: go to a page the trace needs |
currentPath | location.pathname | where 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):
| Event | When |
|---|---|
step | a step starts ({ index, element }) |
stalled | a step can’t find its element, or a wait times out ({ index, reason }) |
page | the guide needs another page ({ index, want, at }) |
handoff | Do it for me hands a masked field to the viewer |
blocked | prepare said not yet |
state | playing, paused and so on |
end | the guide finished |
error | something 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.