Just in case anyone else stumbles across this as I did, I found that the 'steps' array you can pass to setOptions can be accessed in "this._introItems" when Intro is executing.
You can define functions then in the 'steps' array and then execute them at the appropriate time (onchange, etc.) using Intro's built in functions.
// https://introjs.com/docs/intro/options/
//https://introjs.com/example/programmatic/index.html
var options = {
steps: [{
element: '#myElement',
intro: "This step has two functions",
myBeforeChangeFunction: function() {
alert('this is a before change loaded function');
},
myChangeFunction: function() {
alert('this is a change loaded function');
},
},
{
element: '#mySecondElement',
intro: "This has no functions, which is why we need to check for the existence of functions below",
}]
};
var intro = introJs();
// add the options object with the steps/functions above
intro.setOptions(options);
//use the intro.js built in onbeforechange function
intro.onbeforechange(function(){
// check to see if there is a function on this step
if(this._introItems[this._currentStep].myBeforeChangeFunction){
//if so, execute it.
this._introItems[this._currentStep].myBeforeChangeFunction();
}
}).onchange(function() { //intro.js built in onchange function
if (this._introItems[this._currentStep].myChangeFunction){
this._introItems[this._currentStep].myChangeFunction();
}
}).start();
I hope this helps somebody!