提交 26c06289 编写于 作者: D Daniel Castillo 提交者: ULIVZ

fix($core): remove smoothing scroll (close: #1071) (#1075)

上级 3755beb0
......@@ -62,7 +62,15 @@ export function createApp (isServer) {
base: siteData.base,
mode: 'history',
fallback: false,
routes
routes,
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
}
if (to.path !== from.path) {
return { x: 0, y: 0 }
}
}
})
// redirect /foo to /foo/
......
import SmoothScroll from 'smooth-scroll/dist/smooth-scroll.js'
export default {
created () {
this.$vuepress.$on('AsyncMarkdownContentMounted', () => {
this.$vuepress.$set('contentMounted', true)
this.$smoothScroll = new SmoothScroll('a[href*="#"]', {
speed: 1,
speedAsDuration: true,
easing: 'easeInOutCubic'
})
if (this.$route.hash) {
const hash = decodeURIComponent(this.$route.hash)
try {
const anchor = document.getElementById(hash.slice(1))
const anchorLink = anchor.querySelector('a.header-anchor')
setTimeout(() => {
window.scroll({
top: anchorLink.offsetTop - 70,
left: 0,
behavior: 'auto'
})
})
} catch (e) {
console.error(e)
}
}
})
},
watch: {
'$route.path' () {
this.$vuepress.$set('contentMounted', false)
this.$smoothScroll.destroy()
}
},
beforeDestroy () {
this.$smoothScroll.destroy()
}
}
......@@ -55,7 +55,6 @@
"optimize-css-assets-webpack-plugin": "^4.0.0",
"portfinder": "^1.0.13",
"postcss-loader": "^2.1.5",
"smooth-scroll": "^15.0.0",
"toml": "^2.3.3",
"url-loader": "^1.0.1",
"vue": "^2.5.16",
......
......@@ -7606,10 +7606,6 @@ slice-ansi@1.0.0:
dependencies:
is-fullwidth-code-point "^2.0.0"
smooth-scroll@^15.0.0:
version "15.0.0"
resolved "https://registry.yarnpkg.com/smooth-scroll/-/smooth-scroll-15.0.0.tgz#be4f9cb2cc4952d80db6736e5656ed5849305272"
snapdragon-node@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册