tourguide-js icon indicating copy to clipboard operation
tourguide-js copied to clipboard

Pass step indexes to `onBeforeStepChange` and `onAfterStepChange` callbacks

Open mcrampon opened this issue 1 year ago • 0 comments

Changes

This PR adds two arguments to those callbacks:

  • currentStepIndex and stepIndex to onBeforeStepChange
  • previousStepIndex and stepIndex to onAfterStepChange

Example use case:

Before I navigate to the next step, I want to run a callback that includes a condition on which step the user will land on. This is currently not possible, because the callback is called in the same way whether the user pressed the "prev" or the "next" button.

By passing the step indexes to the callbacks, as a developer, I can tell which way the tour is going, and on which step the user will land.

Note

Arguably, this is only required for the onBeforeStepChange callback. In the case of onAfterStepChange, one already has all the necessary information. However, I do feel like it is good to have those arguments as well for convenience and consistency.

mcrampon avatar Apr 08 '25 08:04 mcrampon