mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-01 09:29:02 +08:00
27 lines
549 B
JavaScript
27 lines
549 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
|
|
|| getComputedStyle(element).scrollSnapMarginTop,
|
|
)
|
|
|
|
window.scrollTo(0, top - offset)
|
|
}, 0)
|
|
}
|
|
})
|
|
|
|
}
|