tiptap/docs/gridsome.client.js
2020-10-30 18:11:54 +01:00

24 lines
469 B
JavaScript

export default function (Vue, options, context) {
Vue.mixin({
data() {
return {
cwd: options.cwd,
}
},
})
context.router.afterEach(to => {
if (to.hash) {
setTimeout(() => {
const element = document.getElementById(to.hash.substr(1))
const top = element.offsetTop
const offset = parseFloat(getComputedStyle(element).scrollMarginTop)
window.scrollTo(0, top - offset)
}, 0)
}
})
}