0

I am trying to make Nuxt change routes and appear at the top of the new route, but without seeing it scrolling.
Right now it's either saving the last position, or it's changing the route while scrolling.

I don't want to see the page scrolling.

  1. Setting this code in nuxt.config does nothing:
router: {
  saveScrollPosition: false
}
  1. Setting this code in app/router.scrollBehavior.js scrolls to top visibly:
export default function (to, from, savedPosition) {
  return { x: 0, y: 0 }
}

Nuxt version 2.15.8
Vue version 2.7.10

kissu
  • 40,416
  • 14
  • 65
  • 133
  • Hi, did you tried to set `scrollToTop: true` in your `default.vue` layout? https://nuxtjs.org/docs/directory-structure/pages#scrolltotop – kissu Dec 27 '22 at 16:40
  • Tried this method now and it's still scrolling visibly. The documentation says that it should "scroll to the top before rendering the page", but it scrolls while rendering. – Gabriel Veres Dec 28 '22 at 07:16
  • Then, you should have some CSS getting in the way. How do you fetch your data? – kissu Dec 28 '22 at 10:05
  • I do not fetch any data. Everything is hard coded. I am pretty sure there's something wrong as I am having issues with GSAP. ScrollTrigger works on some elements, and on others stops working after the route changes. Weird. – Gabriel Veres Dec 28 '22 at 11:23
  • Indeed, that one may cause a conflict: https://stackoverflow.com/a/69931622/8816585 – kissu Dec 28 '22 at 11:30

0 Answers0