diff --git a/resources/pages/home/main.vue b/resources/pages/home/main.vue index f9747d9..4e7af07 100644 --- a/resources/pages/home/main.vue +++ b/resources/pages/home/main.vue @@ -20,6 +20,7 @@ const filters = ref({ search: params.search, page: +(props.meta.currentPage || 1), }) +const scrollToTopRef = ref(null) watchDeep(filters, () => { router.visit('/', { @@ -29,6 +30,19 @@ watchDeep(filters, () => { preserveScroll: true, }) }) + +function changePage(newPage: number) { + filters.value.page = newPage + scrollToTop() +} + +function scrollToTop() { + const el = scrollToTopRef.value + + if (el) { + el.scrollIntoView({ behavior: 'smooth' }) + } +}