How to force a scroll up?
-
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.
-
<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>
-
@suleiman_as Thank you. I did not realize that the “element” in the documentation was a DOM one.