Skip to content

Commit

Permalink
feat: add options.debug flag for console output
Browse files Browse the repository at this point in the history
  • Loading branch information
anoff committed Feb 3, 2020
1 parent d2a6cd9 commit effbd1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/components/VStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default {
},
highlight: {
type: Boolean
},
debug: {
type: Boolean
}
},
data () {
Expand All @@ -77,8 +80,9 @@ export default {
},
methods: {
createStep () {
// TODO: debug mode
// console.log('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] is:', targetElement)
if (this.debug) {
console.log('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] is:', this.targetElement)
}
if (this.targetElement) {
this.enableScrolling()
Expand All @@ -91,7 +95,9 @@ export default {
this.params
)
} else {
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
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)
}
},
Expand All @@ -113,7 +119,9 @@ export default {
}
},
isHighlightEnabled () {
console.log(`[Vue Tour] Highlight is ${this.params.highlight ? 'enabled' : 'disabled'} for .v-step[id="${this.hash}"]`)
if (this.debug) {
console.log(`[Vue Tour] Highlight is ${this.params.highlight ? 'enabled' : 'disabled'} for .v-step[id="${this.hash}"]`)
}
return this.params.highlight
},
createHighlight () {
Expand Down
7 changes: 5 additions & 2 deletions src/components/VTour.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:is-last="isLast"
:labels="customOptions.labels"
:highlight="customOptions.highlight"
:debug="customOptions.debug"
>
<!--Default slot {{ currentStep }}-->
<v-step
Expand All @@ -23,6 +24,7 @@
:is-last="isLast"
:labels="customOptions.labels"
:highlight="customOptions.highlight"
:debug="customOptions.debug"
>
<!--<div v-if="index === 2" slot="actions">
<a @click="nextStep">Next step</a>
Expand Down Expand Up @@ -128,8 +130,9 @@ export default {
},
handleKeyup (e) {
// TODO: debug mode
// console.log('[Vue Tour] A keyup event occured:', e)
if (this.customOptions.debug) {
console.log('[Vue Tour] A keyup event occured:', e)
}
switch (e.keyCode) {
case KEYS.ARROW_RIGHT:
this.nextStep()
Expand Down
3 changes: 2 additions & 1 deletion src/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const DEFAULT_OPTIONS = {
buttonStop: 'Finish'
},
startTimeout: 0,
useKeyboardNavigation: true
useKeyboardNavigation: true,
debug: false
}

export const HIGHLIGHT = {
Expand Down

0 comments on commit effbd1d

Please sign in to comment.