mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
fix(vue-app): emit triggerScroll
to support hash navigation (#6012)
This commit is contained in:
parent
a56817f2f8
commit
ac723e6ca6
@ -125,9 +125,16 @@ const scrollBehavior = function (to, from, savedPosition) {
|
||||
position = savedPosition
|
||||
}
|
||||
|
||||
const nuxt = window.<%= globals.nuxt %>
|
||||
|
||||
// triggerScroll is only fired when a new component is loaded
|
||||
if (to.path === from.path && to.hash !== from.hash) {
|
||||
nuxt.$nextTick(() => nuxt.$emit('triggerScroll'))
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
// wait for the out transition to complete (if necessary)
|
||||
window.<%= globals.nuxt %>.$once('triggerScroll', () => {
|
||||
nuxt.$once('triggerScroll', () => {
|
||||
// coords will be used if no selector is provided,
|
||||
// or if the selector didn't match any element.
|
||||
if (to.hash) {
|
||||
|
Loading…
Reference in New Issue
Block a user