Skip to content

Commit

Permalink
feat: add support for Popper's parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Outpox committed Mar 15, 2018
1 parent 20db649 commit 4328c37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/VStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<script>
import Popper from 'popper.js'
import sum from 'hash-sum'
import { DEFAULT_STEP_OPTIONS } from '../shared/constants'
export default {
name: 'v-step',
Expand Down Expand Up @@ -51,8 +52,15 @@ export default {
hash: sum(this.step.target)
}
},
computed: {
params () {
return {
...DEFAULT_STEP_OPTIONS,
...this.step.params
}
}
},
mounted () {
let params = this.step.params || {}
let targetElement = document.querySelector(this.step.target)
// TODO: debug mode
Expand All @@ -62,13 +70,12 @@ export default {
targetElement.scrollIntoView({behavior: 'smooth'})
/* eslint-disable no-new */
new Popper(
let p = new Popper(
targetElement,
this.$refs['v-step-' + this.hash],
{
placement: params.placement ? params.placement : 'bottom'
}
this.params
)
console.log(p.options.modifiers.offset)
} else {
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
this.stop()
Expand Down
4 changes: 4 additions & 0 deletions src/shared/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const DEFAULT_OPTIONS = {
startTimeout: 0
}

export const DEFAULT_STEP_OPTIONS = {
placement: 'bottom'
}

export const KEYS = {
ARROW_RIGHT: 39,
ARROW_LEFT: 37,
Expand Down

0 comments on commit 4328c37

Please sign in to comment.