No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    router.beforeEach not scrolling to the top of the window after route changes...

    Help
    3
    7
    4137
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      robmpreston last edited by

      Another dumb one I’m sure… backend guys doing frontend… who knew it was a bad idea?!

      In router.js I have:
      let Router = new VueRouter()

      Router.map(routes)

      Router.beforeEach(function (transition) {
      window.scrollTo(0, 0)
      transition.next()
      })

      When I change routes, the window retains its position (i.e. if im scrolled down far on one page, I am then scrolled down far on the next page when I switch routes)

      1 Reply Last reply Reply Quote 0
      • R
        robmpreston last edited by

        wtf? i was in the help forum when i posted this. LOL sorry

        1 Reply Last reply Reply Quote 0
        • rstoenescu
          rstoenescu Admin last edited by

          Haven’t figured out how to move this to “Help” category without tampering with the DB which I’d avoid.
          Anyway, instead of window.scrollTo(0, 0) try document.body.scrollTop = document.documentElement.scrollTop = 0.

          This will not work with Layouts, so let me know if this is the case as it deserves a more detailed answer.

          1 Reply Last reply Reply Quote 0
          • R
            robmpreston last edited by robmpreston

            That didnt seem to work either. No scrolling at all, stays in the same place.

            Definitely hitting the function, and yeah its inside of a quasar-layout

            1 Reply Last reply Reply Quote 0
            • rstoenescu
              rstoenescu Admin last edited by

              For whomever asks what happened with this issue, well it has been solved outside of the forum through email. There were CSS hacks in Robert’s code that broke the layout.

              1 Reply Last reply Reply Quote 0
              • rstoenescu
                rstoenescu Admin last edited by

                Use Vue Router 3.0 and add scrollBehavior: () => ({ y: 0 }) to the new Router definition.

                1 Reply Last reply Reply Quote 0
                • T
                  terumi last edited by

                  If you are on cordova, you can add a setTimeOut to, say 10 ms, because the new route hasn’t been loaded already. After the 10ms expiry the screen will jump to the desired position.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post