Static GitHub Issues

[957] Changing ScrollToTop behavior stoped working.

prev: alpine causing segmen fault on build
next: Assets path resolution not working for tags different than <img>

I used this fix

~plugins/scrolltotop.js

import router from '~router'

router.afterEach((to, from) => {
  // set timeout time to time of your transition
  setTimeout(() => {
    // dunno why but conditional helps to speed up build time despite ssr: false…
    if (document) document.body.scrollTop = 0
  }, 500)
})

nuxt.config.js

router: {
    scrollBehavior: function (to, from, savedPosition) {
      return { x: false, y: false }
    }
},

plugins: [
    {
      src: '~plugins/router-guards',
      ssr: false
    },
]

Now it throwing me error

 warning  in ./plugins/scrolltotop.js

3:0-6 "export 'default' (imported as 'router') was not found in '~router'

And transitions stoped working.

I see @Atinux removed this issue from Roadmap. Will it be implemented from the box or not? This hack is pretty ugly.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c822">#c822</a>)</em></sub></div>