Tour
Lifecycle events for tour start, finish, close, navigation, and step changes.
Tour events fire during the tour lifecycle — when it starts, finishes, closes, and when the user navigates between steps. All events are accessible through instance.api.events.
Events
| Event | String value | When |
|---|---|---|
ON_TOUR_START | tour:start | Tour initialises on mount |
ON_TOUR_FINISH | tour:finish | Last step is completed |
ON_TOUR_CLOSE | tour:close | Tour is dismissed before completion |
ON_TOUR_NEXT | tour:next | User advances to the next step (not on last step) |
ON_TOUR_PREV | tour:prev | User navigates to the previous step |
ON_TOUR_STEP_CHANGE | tour:step-change | Active step changes (any navigation) |
Usage
import { BordaEvent } from '@retoo/borda';
instance.api.events.on(BordaEvent.ON_TOUR_START, () => {
analytics.track('tour_started');
});
instance.api.events.on(BordaEvent.ON_TOUR_NEXT, () => {
analytics.track('tour_step_next', { step: instance.api.controller.currentStep });
});
instance.api.events.on(BordaEvent.ON_TOUR_FINISH, () => {
analytics.track('tour_completed');
});
instance.api.events.on(BordaEvent.ON_TOUR_CLOSE, () => {
analytics.track('tour_dismissed');
});
instance.api.events.on(BordaEvent.ON_TOUR_STEP_CHANGE, () => {
console.log('Now on step', instance.api.controller.currentStep);
});
Unsubscribing
Pass the same handler reference to off():
const handler = () => console.log('finished');
instance.api.events.on(BordaEvent.ON_TOUR_FINISH, handler);
// Later
instance.api.events.off(BordaEvent.ON_TOUR_FINISH, handler);
Notes
ON_TOUR_STARTfires once after the first step is rendered.ON_TOUR_FINISHfires before the unmount animation begins.ON_TOUR_CLOSEfires when the user dismisses the tour via the close button, backdrop click, or Escape key.ON_TOUR_STEP_CHANGEfires on every navigation — includingnext,prev,changeStep, andfinish.ON_TOUR_NEXT/ON_TOUR_PREValso fire on tooltip swipe gestures on touch devices.