tourguide-js
tourguide-js copied to clipboard
Pass step indexes to `onBeforeStepChange` and `onAfterStepChange` callbacks
Changes
This PR adds two arguments to those callbacks:
-
currentStepIndexandstepIndextoonBeforeStepChange -
previousStepIndexandstepIndextoonAfterStepChange
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.