vue-tour
vue-tour copied to clipboard
Support next/prev function with the behavior that step is skipped with TargetNotFound
This is not a bug. This function will improve vue-tour behavior when the tag element is not founded.
I use next/prev override function like below. How do you think it supported in vue-tour with selectable option?
nextStepTour(currentStep) {
for (var i = currentStep + 1; i < this.steps.length; i++) {
const target_element = document.querySelector(this.steps[i].target);
if (target_element) {
if (i == currentStep + 1) {
break;
} else {
const tour = this.$tours["home"];
this.$nextTick(() => {
tour.currentStep = i;
});
break;
}
}
}
},
previousStepTour(currentStep) {
for (var i = currentStep - 1; i > -1; i--) {
const target_element = document.querySelector(this.steps[i].target);
if (target_element) {
if (i == currentStep - 1) {
break;
} else {
const tour = this.$tours["home"];
this.$nextTick(() => {
tour.currentStep = i;
});
break;
}
}
}
}
Maybe we need to add additional codes to check last step to change buttons showing.
@quroom how do you account for the events that are meant to be triggered before the step. For example: if I assign a click event to a dropdown before highlighting the dropdown so that i could highlight it's active state but if I use these custom navigation functions then it would fail to find the element in the dom and skips that step. Dom would only see that element when it is clicked.