Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: add after() step #219

Open
regexj opened this issue Feb 11, 2022 · 0 comments
Open

Request: add after() step #219

regexj opened this issue Feb 11, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@regexj
Copy link

regexj commented Feb 11, 2022

Before step is described here: https://github.com/pulsardev/vue-tour/wiki/Features

Please add the same functionality but for an after() step function. A callback for that specific step.

There are some cases where I would like to make XHR requests or modify the page contents after a step has loaded, not before. My current workaround is so:

//in case we have an after at the start, make sure it's triggered
onStartCallback () {
  this.runAnAfter();
}

previousStepCallback () {
  --this.vueTour.currentPageStep;
  this.runAnAfter();
}

nextStepCallback () {
  ++this.vueTour.currentPageStep;
  this.runAnAfter();
}

runAnAfter () {
  const step = this.vueTour.currentPageStep;
  if( this.vueTour.steps[step].after ){
    // @ts-ignore
    this.vueTour.steps[step].after();
  }
}

Then I've expanded the steps object to include that function

{
  target: '.not-found-wrapper',
  content: this.$t('vueTour.welcome.page.home.step2') as string,
  params: {
    placement: VueTourPlacement.Top
  },
  before: () => new Promise((resolve) => {
    //some logic here
    resolve(true);
  }),
  after: () => new Promise((resolve) => {
    //some logic here - e.g. xhr request prepares content for the next step without delaying the experience of loading the current step
    resolve(true);
  })
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants