mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 19:59:02 +08:00
improve scroll position
This commit is contained in:
parent
7e33b748d1
commit
a6041f2723
@ -59,6 +59,10 @@ body {
|
||||
color: $colorText;
|
||||
}
|
||||
|
||||
*[id] {
|
||||
scroll-margin-top: 6rem;
|
||||
}
|
||||
|
||||
button {
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
|
@ -5,9 +5,30 @@ import 'prismjs/components/prism-scss.js'
|
||||
import PortalVue from 'portal-vue'
|
||||
import App from '~/layouts/App'
|
||||
|
||||
export default function (Vue) {
|
||||
export default function (Vue, { router }) {
|
||||
Vue.use(PortalVue)
|
||||
Vue.component('Layout', App)
|
||||
Vue.component('Demo', () => import(/* webpackChunkName: "demo" */ '~/components/Demo'))
|
||||
Vue.component('LiveDemo', () => import(/* webpackChunkName: "live-demo" */ '~/components/LiveDemo'))
|
||||
|
||||
router.options.scrollBehavior = async (to, from, savedPosition) => {
|
||||
if (to.hash) {
|
||||
const elem = document.querySelector(to.hash)
|
||||
|
||||
if (elem) {
|
||||
const offset = parseFloat(getComputedStyle(elem).scrollMarginTop)
|
||||
return {
|
||||
selector: to.hash,
|
||||
offset: { y: offset },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (savedPosition) {
|
||||
return savedPosition
|
||||
}
|
||||
|
||||
return { x: 0, y: 0 }
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user