Unverified Commit 4d2d6154 authored by Seyed Sajad Kahani's avatar Seyed Sajad Kahani Committed by GitHub

fix: change nextTick to onload for anchor scrolling (#1870)

* change nextTick to onload for anchor scrolling * fix: handle anchor scrollTo if page already loaded Co-authored-by: 's avatarNicolas Giard <github@ngpixel.com>
parent 4d149988
...@@ -460,11 +460,19 @@ export default { ...@@ -460,11 +460,19 @@ export default {
}) })
// -> Handle anchor scrolling // -> Handle anchor scrolling
this.$nextTick(() => {
if (window.location.hash && window.location.hash.length > 1) { if (window.location.hash && window.location.hash.length > 1) {
if (document.readyState === 'complete') {
this.$nextTick(() => {
this.$vuetify.goTo(window.location.hash, this.scrollOpts)
})
} else {
window.addEventListener('load', () => {
this.$vuetify.goTo(window.location.hash, this.scrollOpts) this.$vuetify.goTo(window.location.hash, this.scrollOpts)
})
}
} }
this.$nextTick(() => {
this.$refs.container.querySelectorAll(`a[href^="#"], a[href^="${window.location.href.replace(window.location.hash, '')}#"]`).forEach(el => { this.$refs.container.querySelectorAll(`a[href^="#"], a[href^="${window.location.href.replace(window.location.hash, '')}#"]`).forEach(el => {
el.onclick = ev => { el.onclick = ev => {
ev.preventDefault() ev.preventDefault()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment