Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(pagination): emit "page-change" event after page has changed
Browse files Browse the repository at this point in the history
allows to listen for page change and to act upon it for example for scrolling to the top of the page.

Closes: #231
  • Loading branch information
rayrutjes committed Aug 5, 2017
1 parent 035dcea commit a259cc5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ export default {
},
methods: {
goToPage(page) {
const p = Math.max(1, page);
this.searchStore.page = Math.min(this.totalPages, p);
let p = Math.max(1, page);
p = Math.min(this.totalPages, p);
if (this.searchStore.page === p) {
return;
}
this.searchStore.page = p;
this.$emit('page-change');
},
goToFirstPage() {
this.goToPage(1);
Expand Down

0 comments on commit a259cc5

Please sign in to comment.