Skip to content

Commit

Permalink
feat: enable specific navigation keys
Browse files Browse the repository at this point in the history
  • Loading branch information
bsl333 committed May 30, 2020
1 parent a48792f commit 89ff650
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/VTour.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,19 @@ export default {
}
switch (e.keyCode) {
case KEYS.ARROW_RIGHT:
this.nextStep()
this.isKeyEnabled('ARROW_RIGHT') && this.nextStep()
break
case KEYS.ARROW_LEFT:
this.previousStep()
this.isKeyEnabled('ARROW_LEFT') && this.previousStep()
break
case KEYS.ESCAPE:
this.stop()
this.isKeyEnabled('ESCAPE') && this.stop()
break
}
},
isKeyEnabled (key) {
const { enabledNavigationKeys } = this.customOptions
return enabledNavigationKeys.hasOwnProperty(key) ? enabledNavigationKeys[key] : true
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const DEFAULT_OPTIONS = {
},
startTimeout: 0,
useKeyboardNavigation: true,
enabledNavigationKeys: {
ESCAPE: true,
ARROW_RIGHT: true,
ARROW_LEFT: true
},
debug: false
}

Expand Down

0 comments on commit 89ff650

Please sign in to comment.