Giter Club home page Giter Club logo

Comments (3)

pzero24 avatar pzero24 commented on August 16, 2024 3

@AlexCln what I did to solve this problem is have an anchor point off the screen. I would then use that anchor point as a transition step. So my step configuration was something like this:

[
    {
       stepId: 'firstStep'
       anchorId: 'some.anchor.id'
    },
    {
       stepId: 'toggleMenuRedirect'
       anchorId: 'offscreenAnchor'
    },
    {
        prevStep: 'firstStep',
        stepId: 'menuStep'
        anchorId: 'menu.anchor.id'
    }
]

then I would use the stepShow$ to detect when you are going to the toggleMenuRedirect step and then go to the next step:

this.tourService.stepShow$.subscribe( (step: IStepOption) => {
   switch (step.stepId){
       case "toggleMenuRedirect":
            this.myVariable = true;
            this.tourService.next();
       break;
  }
});

then on the stepHide$ callback of the menuStep step, you would set it back to false

this.tourService.stepHide$.subscribe( (step: IStepOption) => {
   switch (step.stepId){
       case "menuStep":
            this.myVariable = false;
       break;
  }
});

This is a bit of a workaround though. It would be nice @isaacplmann if there could be functions on the IStepOption object for onEnter and onLeave that would wait for the function to finish in the case of it returning a Promise or an Observable.

from ngx-tour.

isaacplmann avatar isaacplmann commented on August 16, 2024

Yes. The stepShow$ observable emits a value every time a new step is shown. So you can use it like this:

// step2 is defined up here somewhere
this.tourService.stepShow$.subscribe((step: IStepOption) => {
  if (step === step2) { // or step.anchorId === step2.anchorId
    this.myVariable = 'This is step 2!';
  }
});

Note: This code will execute any time step 2 is shown - so if you start the tour directly on step 2 or go from step 1 to 2 or from step 3 back to 2.

from ngx-tour.

AlexCln avatar AlexCln commented on August 16, 2024

Thanks for your answer, I've found a solution:

In app.component.ts :

this.tourService.stepShow$.subscribe( (res: any) => {
   switch (res.Step){
       case"2":
       this.myVariable = true;
       break;
       .... 
  }
});

and to close :

this.tourService.stepHide$.subscribe( (res: any) => {
   switch (res.Step){
       case"2": //for the same step
       this.myVariable = false;
       break;
       ....
  }
});

Now I got a position problem with the card because my toggleMenu is in position: absolute and the card is fixed to top: 0px; left: 0px

Regards

from ngx-tour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.