lokyoung / vuejs-paginate

A Vue.js(v2.x+) component for creating pagination.
MIT License
779 stars 171 forks source link

Force scroll back to top #115

Open GonrasK opened 4 years ago

GonrasK commented 4 years ago

How do i force scroll back to top after moving from page to page (clicking 'next' or on the page's number)? In case my pagination is below the search results.

<paginate v-if="page_count > 1" v-model="page" :page-range="8" :pageCount="page_count" :containerClass="'pagination'" :clickHandler="clickCallback" :prev-text="'Prev'" :next-text="'Next'" > </paginate>

flyingL123 commented 4 years ago

I'm doing that in the click handler. I place a ref at the top of my content, and then scroll it into view:

<div ref="top"></div>
<div>
    <!-- my paginating content -->
</div>
<paginate :click-handler="onPaginate"/>

Then in the onPaginate method:

function onPaginate () {
    this.$refs.top.scrollIntoView();
}