Skip to content

API reference

typescript
import {busk} from '@logfox/busker';
const show = busk(root, routine);

Puts on a show inside root, an HTMLElement. Returns a Busker. Starts by itself once the root is on screen.

A routine is one of two things, never a mix. A ScriptRoutine has steps and gets its loop length from them; a TimedRoutine has a duration you set yourself. Mixing the two is a type error, so a hand-set duration can never quietly cut a script short.

FieldTypeDefaultWhat it does
stepsStep[]A click-driven routine. Required in a ScriptRoutine.
durationnumberLoop length in ms. Required in a TimedRoutine.
movesMove[]noneHand-timed cursor glides. TimedRoutine only.

Everything else is shared:

FieldTypeDefaultWhat it does
initialScenestringnoneScene shown at the top of every loop.
start[number, number][0.5, 0.5]Where the cursor rests, as a fraction of the root’s size.
routesRoute[]noneWhat a click — the cursor’s or a visitor’s — does.
togglesToggle[]noneClasses held for a slice of the loop.
typingTyping[]noneText that types itself.
countdownsCountdown[]nonem:ss clocks.
visibilitynumber1How much of the root must be on screen to run, as a fraction.
freezeAtnumber0Frame to hold under prefers-reduced-motion.

One beat of a click-driven routine. Either a press:

FieldTypeDefault
clickstring
waitnumber0
moveFornumber600
dwellnumber250

…or a drift, which never clicks:

FieldTypeDefault
tostring | [number, number]
waitnumber0
moveFornumber600

Beats run back to back: a step sets off wait after the last one finished.

FieldTypeWhat it does
clickstringSelector of the clickable element.
scenestringdata-scene to show when it is clicked.

Every route target also gets is-interactive, which is what makes it look clickable.

A hand-timed glide. See Hand-timed routines.

FieldTypeWhat it does
tostring | [number, number]Where to glide.
fromnumberWhen it sets off.
untilnumberWhen it arrives.
pressnumberOptional. Animates a press. Does not click.
FieldTypeWhat it does
targetstringSelector of the element.
classstringClass held while the loop is inside [from, until).
fromnumber
untilnumber
FieldTypeWhat it does
targetstringSelector. Busker writes its textContent.
textstring
fromnumberTyping starts.
untilnumberThe whole string is on screen.
clearAtnumberOptional. Wipes it.
FieldTypeWhat it does
targetstringSelector. Busker writes its textContent.
startSecondsnumberValue at the top of every loop. Counts down to zero and stops.
MemberWhat it does
durationLoop length in ms: what you set, or what the steps add up to.
play()Start or resume. A no-op once a visitor has taken over.
pause()Hold where it is.
stepAside()Hand the mock to the visitor: stop for good, hide the cursor.
destroy()Stop everything and remove every class, listener, and observer busker added.

Styling · Next: Development