Made tour node registration a bit more forgiving when waiting for tour details to initialise
This commit is contained in:
parent
c27ce2a3b0
commit
19d7c94a22
|
@ -8,18 +8,26 @@
|
||||||
|
|
||||||
let currentTourStep
|
let currentTourStep
|
||||||
let ready = false
|
let ready = false
|
||||||
|
let registered = false
|
||||||
let handler
|
let handler
|
||||||
|
|
||||||
|
const registerTourNode = (tourKey, stepKey) => {
|
||||||
|
if (ready && !registered && tourKey) {
|
||||||
|
currentTourStep = TOURS[tourKey].find(step => step.id === stepKey)
|
||||||
|
if (!currentTourStep) {
|
||||||
|
console.log("Could not find tour step : ", stepKey)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const elem = document.querySelector(currentTourStep.query)
|
||||||
|
handler = tourHandler(elem, stepKey)
|
||||||
|
registered = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: tourKeyWatch = $store.tourKey
|
||||||
|
$: registerTourNode(tourKeyWatch, tourStepKey, ready)
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!$store.tourKey) return
|
|
||||||
|
|
||||||
currentTourStep = TOURS[$store.tourKey].find(
|
|
||||||
step => step.id === tourStepKey
|
|
||||||
)
|
|
||||||
if (!currentTourStep) return
|
|
||||||
|
|
||||||
const elem = document.querySelector(currentTourStep.query)
|
|
||||||
handler = tourHandler(elem, tourStepKey)
|
|
||||||
ready = true
|
ready = true
|
||||||
})
|
})
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
|
Loading…
Reference in New Issue