mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-25 21:35:53 +08:00
16 lines
380 B
JavaScript
16 lines
380 B
JavaScript
|
export default function (Vue, options, context) {
|
||
|
|
||
|
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)
|
||
|
}
|
||
|
})
|
||
|
|
||
|
}
|