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

    How to force a scroll up?

    Help
    2
    3
    147
    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.
    • W
      wpq last edited by

      I would like to force the page to scroll up following an event (say, following an @click action on a button).

      As an example, I saw this kind of action on floating buttons on the lower-right part of a page.

      I saw that there are some scroll utilities at https://quasar.dev/quasar-utils/scrolling-utils but it is not clear for me how to address the ‘top of the page’ aspect.

      S 1 Reply Last reply Reply Quote 0
      • S
        suleiman_as @wpq last edited by

        @wpq

        <script>
        import { scroll } from "quasar";
        const { getScrollTarget, setScrollPosition } = scroll;
        
        export default {
          methods: {
            toTop() {
              // get the element first, it's up to you
              // const el = this.$refs.anything.$el;
              const el = document.querySelector(".q-page-container");
              const duration = 1000;
              // scroll to (Vertically)
              setScrollPosition(getScrollTarget(el), el.offsetTop, duration);
            }
          }
        };
        </script>
        
        1 Reply Last reply Reply Quote 0
        • W
          wpq last edited by

          @suleiman_as Thank you. I did not realize that the “element” in the documentation was a DOM one.

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