Made tour node registration a bit more forgiving when waiting for tour details to initialise

This commit is contained in:
Dean 2023-03-13 13:17:26 +00:00
parent c27ce2a3b0
commit 19d7c94a22
1 changed files with 17 additions and 9 deletions

View File

@ -8,18 +8,26 @@
let currentTourStep let currentTourStep
let ready = false let ready = false
let registered = false
let handler let handler
onMount(() => { const registerTourNode = (tourKey, stepKey) => {
if (!$store.tourKey) return if (ready && !registered && tourKey) {
currentTourStep = TOURS[tourKey].find(step => step.id === stepKey)
currentTourStep = TOURS[$store.tourKey].find( if (!currentTourStep) {
step => step.id === tourStepKey console.log("Could not find tour step : ", stepKey)
) return
if (!currentTourStep) return }
const elem = document.querySelector(currentTourStep.query) const elem = document.querySelector(currentTourStep.query)
handler = tourHandler(elem, tourStepKey) handler = tourHandler(elem, stepKey)
registered = true
}
}
$: tourKeyWatch = $store.tourKey
$: registerTourNode(tourKeyWatch, tourStepKey, ready)
onMount(() => {
ready = true ready = true
}) })
onDestroy(() => { onDestroy(() => {