Skip to content

Commit d53273d

Browse files
authored
Merge pull request #43 from GlobalHive/42-goToStepFeature
42 go to step feature
2 parents f5b67c6 + 28d458b commit d53273d

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
on:
22
workflow_dispatch:
3+
pull_request:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
39

410
name: 1 Release Please
511
jobs:

src/components/VTour.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { createPopper } from "@popperjs/core";
1919
import { computed, onMounted, reactive, ref } from "vue";
2020
import jump from "jump.js";
2121
22+
const tourStarted = ref(false);
2223
const popper = ref(null);
2324
const step = reactive({
2425
currentStep: 0,
@@ -80,6 +81,7 @@ defineExpose({
8081
nextStep,
8182
prevStep,
8283
endTour,
84+
goToStep,
8385
resetTour
8486
});
8587
@@ -114,6 +116,7 @@ async function startTour() {
114116
});
115117
props.highlight ? highlightTarget() : null;
116118
emit("onTourStart");
119+
tourStarted.value = true;
117120
}, props.startDelay);
118121
}
119122
function highlightTarget() {
@@ -158,6 +161,19 @@ function endTour() {
158161
});
159162
emit("onTourEnd");
160163
}
164+
165+
async function goToStep(nextStep){
166+
if(tourStarted.value === false) await startTour();
167+
step.getCurrentStep.onNext ? await step.getCurrentStep.onNext() : null;
168+
step.lastStep = nextStep - 1 >= 0 ? nextStep - 1 : 0;
169+
step.currentStep = nextStep;
170+
if(props.saveToLocalStorage === 'step') localStorage.setItem("vjt-" + props.name, step.currentStep);
171+
while(document.querySelector(`${step.getCurrentStep.target}`) === null) {
172+
step.currentStep++;
173+
}
174+
await recalculatePopper();
175+
}
176+
161177
function resetTour() {
162178
step.currentStep = 0;
163179
step.lastStep = 0;

0 commit comments

Comments
 (0)