usablica / intro.js

Lightweight, user-friendly onboarding tour library
http://introjs.com
Other
22.76k stars 2.59k forks source link

How to click on the background in the guide step to also proceed to the next step #1917

Closed llllzzzzzhhhhh closed 1 year ago

llllzzzzzhhhhh commented 1 year ago

Description

Describe one (and only one) issue or enhancement you want to see in Intro.js (before writing any code).

Expected Behavior

What did you expect to happen?

Actual Behavior

I'm adding a custom event to the onbeforechange() event and want to do a click on the background for the next step, but I can't get the instance

Errors and Screenshots (optional)

  this.$intro()
    .setOptions(this.introOption)
    .oncomplete(() => {
      this.$router.push('/smk')
    })
    .onbeforechange(()=> {
      const stepBackdrop = document.querySelector('.introjs-overlay');
      stepBackdrop.addEventListener('click',()=>{
       // console.log('User clicked the backdrop.');
        // console.log(targetElement);
       // this.$intro().nextStep().start();
        // debugger
        // const currentStep = _this.$intro()._currentStep;
        // console.log(`Current step: ${currentStep}`);
      });
    })
    .onexit(() => {
      console.log("onexit");
    })
    .onbeforeexit(() => {
      console.log("onbeforeexit");
    })
    .onchange(function (res) {
      console.log(res.id);
      if (res.id == 'step4') {
         window.scrollTo(0, 100)
      }
      if (res.id == 'step2') {
         window.scrollTo(0, 850)
      }
      // count = parseInt(targetElement.id.slice(-1))
    })
    .start();

Example (recommended)

Environment (optional)

Vue2 intro.js

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.