Skip to content

Commit

Permalink
Merge branch 'develop' into smitpatelx-master
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorainville committed Mar 28, 2021
2 parents 79fe4e5 + 20a3478 commit dca8f20
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/vue-tour.common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vue-tour.common.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vue-tour.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 39 additions & 17 deletions src/components/VStep.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="v-step" :id="'v-step-' + hash" :ref="'v-step-' + hash">
<div v-bind:class="{ 'v-step--sticky': isSticky }" class="v-step" :id="'v-step-' + hash" :ref="'v-step-' + hash">
<slot name="header">
<div v-if="step.header" class="v-step__header">
<div v-if="step.header.title" v-html="step.header.title"></div>
Expand Down Expand Up @@ -95,6 +95,12 @@ export default {
...{ enabledButtons: Object.assign({}, this.enabledButtons) },
...this.step.params // Then use local step parameters if defined
}
},
/**
* A step is considered sticky if it has no target.
*/
isSticky () {
return !this.step.target
}
},
methods: {
Expand All @@ -103,23 +109,27 @@ export default {
console.log('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] is:', this.targetElement)
}
if (this.targetElement) {
this.enableScrolling()
this.createHighlight()
/* eslint-disable no-new */
createPopper(
this.targetElement,
this.$refs['v-step-' + this.hash],
this.params
)
if (this.isSticky) {
document.body.appendChild(this.$refs['v-step-' + this.hash])
} else {
if (this.debug) {
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
}
this.$emit('targetNotFound', this.step)
if (this.stopOnFail) {
this.stop()
if (this.targetElement) {
this.enableScrolling()
this.createHighlight()
/* eslint-disable no-new */
new Popper(
this.targetElement,
this.$refs['v-step-' + this.hash],
this.params
)
} else {
if (this.debug) {
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
}
this.$emit('targetNotFound', this.step)
if (this.stopOnFail) {
this.stop()
}
}
}
},
Expand Down Expand Up @@ -203,8 +213,20 @@ export default {
rgba(0, 0, 0, 0.1) 0px 4px 6px -1px,
rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
padding: 1rem;
pointer-events: auto;
text-align: center;
z-index: 10000;
&--sticky {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
& .v-step__arrow {
display: none;
}
}
}
.v-step__arrow,
Expand Down
9 changes: 5 additions & 4 deletions src/components/VTour.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ export default {
},
mounted () {
this.$tours[this.name] = this
if (this.customOptions.useKeyboardNavigation) {
window.addEventListener('keyup', this.handleKeyup)
}
},
beforeDestroy () {
// Remove the keyup listener if it has been defined
Expand Down Expand Up @@ -116,6 +112,11 @@ export default {
},
methods: {
async start (startStep) {
// Register keyup listeners for this tour
if (this.customOptions.useKeyboardNavigation) {
window.addEventListener('keyup', this.handleKeyup)
}
// Wait for the DOM to be loaded, then start the tour
startStep = typeof startStep !== 'undefined' ? parseInt(startStep, 10) : 0
let step = this.steps[startStep]
Expand Down

0 comments on commit dca8f20

Please sign in to comment.