Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change 'overlayOpacity' just for one step with intro.js?

I want to change the 'overlayOpacity' option to 0.5 for only one specific step. How can I realize this functionality and change that parameter back to the default value?

Examples, which do not work:

introJs().step2().setOption("overlayOpacity", 0.5);

if(introJs().step2()){
  introJs().setOption("overlayOpacity", 0.5);
}
like image 305
David Avatar asked Jan 28 '26 17:01

David


1 Answers

The API documentation of intro.js is not super clear, but I found one example in the repository, that might give you an idea how to solve your problem:

  1. Listen for the step changes
  2. Check for _currentStep equals the desired step
introJs().onbeforechange(function() {
  if (this._currentStep === 1) {
    introJs().setOption("overlayOpacity", 0.5);
  } else {
    introJs().setOption("overlayOpacity", 0.8);
  }
});

Note: The default parameter of overlayOpacity is 0.8 and should be changed back, if the user left the desired step. And keep in mind, that this listener fires the callback function before the step change. Therefore we need currentStep === 1, instead of 2.

like image 76
Michael Czechowski Avatar answered Jan 30 '26 08:01

Michael Czechowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!