Comments (7)
Thanks for the pointer - I have made it a bit more generic so that it automatically pushes a route when you need to, and then waits for it to load.
<v-tour name="introTour"
:steps="introSteps">
<template slot-scope="tour">
<transition name="fade">
<v-step v-if="tour.currentStep === index"
v-for="(step, index) of tour.steps"
:key="index"
:step="step"
:previous-step="tour.previousStep"
:next-step="tour.nextStep"
:stop="tour.stop"
:is-first="tour.isFirst"
:is-last="tour.isLast"
:labels="tour.labels">
<div slot="actions">
<div class="v-step__buttons">
<button @click.prevent="tour.stop"
v-if="!tour.isLast">{{ labels.buttonSkip }}</button>
<button @click.prevent="introGoPrev(tour)"
v-if="!tour.isFirst">{{ labels.buttonPrevious }}</button>
<button @click.prevent="introGoNext(tour)"
v-if="!tour.isLast">{{ labels.buttonNext }}</button>
<button @click.prevent="tour.stop"
v-if="tour.isLast">{{ labels.buttonStop }}</button>
</div>
</div>
</v-step>
</transition>
</template>
</v-tour>
And then in the data I specify the steps where it needs to go to a specific route:
introSteps: [
{
target: '#intro-step-0',
header: { title:'This is a header' },
content: 'Test of tour',
},
{
route: '/services',
target: '#intro-step-1',
content: 'Here we are',
},
],
And pick it up in my methods:
introGoNext(tour) {
if (tour.steps[tour.currentStep + 1].route) {
this.$router.push(tour.steps[tour.currentStep + 1].route)
this.$nextTick(() => {
tour.nextStep()
})
} else {
tour.nextStep()
}
},
introGoPrev(tour) {
if (tour.steps[tour.currentStep - 1].route) {
this.$router.push(tour.steps[tour.currentStep - 1].route)
this.$nextTick(() => {
tour.previousStep()
})
} else {
tour.previousStep()
}
},
Hope this is useful
from vue-tour.
Hi guys, have you given a look to the startTimeout
property ?
Check the doc for an example.
Edit: You maybe meant a delay between each step? If so take a look at the custom callbacks in the doc. I believe you should be able to use a setTimeout()
to fulfil your need. Let me know if you need more help.
from vue-tour.
+1
I also need this feature.
from vue-tour.
Hi, thanks for getting back to us, yeah I want to have a delay between each step so using a custom call back sounds like it could help although its not clear from the docs how to delay/defer the next step while the custom call back runs, but this is exactly what I would need. Maybe something like this:
myCustomNextStepCallback (currentStep) {
this.$tours['myTour'].pause()
// do something async
setTimeout ( () => this.$tours['myTour'].resume(), 1000);
}
Although if nothing exists like this already a better approach would be to allow us to define more options in the param
object of a step (like hopscotch which has many more options - which I recommend you also consider providing things like offsets )
{
target: '#autoCompleteResults li:first-child',
content: '....',
params: {
placement: 'bottom',
delay: 2000
}
},
UPDATE: I did manage to figure this out via a custom template but its a lot of code to just add a delay:
<v-tour name="myTour" :steps="steps" :callbacks="myCallbacks">
<template slot-scope="tour">
<transition name="fade">
<v-step
v-if="tour.currentStep === index"
v-for="(step, index) of tour.steps"
:key="index"
:step="step"
:previous-step="tour.previousStep"
:next-step="tour.nextStep"
:stop="tour.stop"
:isFirst="tour.isFirst"
:isLast="tour.isLast"
>
<template v-if="tour.currentStep === 1">
<div slot="actions">
<button @click="tour.previousStep"
class="btn btn-primary">Previous step
</button>
<button @click="doSecondStep(tour)"
class="btn btn-primary">Next step
</button>
</div>
</template>
</v-step>
</transition>
</template>
</v-tour>
..
..
..
..
doSecondStep(tour) {
this.onSecondStep()
setTimeout ( () => tour.nextStep(), 2000);
}
from vue-tour.
It seems @pbascunana made a PR at #122
Just to comment that I solved the a problem in a different way... each of my steps has an event hook (e.g. DOM element clicked/appears) which auto-moves to that next step. Aside from solving the display issue, it also means you move to the next step automatically if the user triggered the page change themselves.
from vue-tour.
Hi all,
Actually @buwilliams has made a PR to add a before
hook that handles asynchronous actions using Promises.
This is way more flexible than adding a param in the step with a fixed delay, that's why we've decided to merge his PR (#84) rather than the one from @pbascunana (but thanks anyway for the contribution!).
from vue-tour.
The PR has been merged and released in v1.5.0.
from vue-tour.
Related Issues (20)
- finish prop is missing in Customizing the Template inside Documentation
- Build fails in vue-tour (npm run build)
- Tour stops when targets aren't found HOT 2
- Memory leak when using VueTour in vue-test-utils [BUG]
- Vue 3 Compatibility HOT 5
- Is there a way to install locally rather than globally HOT 1
- Unable to point to elements in child components using vue 2 and quasar
- Disable interaction with any elements while tour is displayed HOT 3
- Stop the tour HOT 1
- After adding v-if to the component, the component will not be destroyed if the condition is false. HOT 2
- Install with Nuxt3 HOT 2
- Embed Image in tour HOT 1
- Can I pause a tour? HOT 1
- How to integrate with vite ? HOT 2
- Cross iFrame
- Switching from vue-cli to vite
- the callback which name is onFinish does not trigger HOT 1
- In modal position of the v-step is wrong
- Support for nuxt 3
- Slots will be added very shortly to support with vue 3.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-tour.