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

Commit a259cc5

Browse files
committed
feat(pagination): emit "page-change" event after page has changed
allows to listen for page change and to act upon it for example for scrolling to the top of the page. Closes: #231
1 parent 035dcea commit a259cc5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/Pagination.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,13 @@ export default {
9090
},
9191
methods: {
9292
goToPage(page) {
93-
const p = Math.max(1, page);
94-
this.searchStore.page = Math.min(this.totalPages, p);
93+
let p = Math.max(1, page);
94+
p = Math.min(this.totalPages, p);
95+
if (this.searchStore.page === p) {
96+
return;
97+
}
98+
this.searchStore.page = p;
99+
this.$emit('page-change');
95100
},
96101
goToFirstPage() {
97102
this.goToPage(1);

0 commit comments

Comments
 (0)