From 7c240a563bf227eb94003ff35e83bc167a09cebf Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sun, 1 Jan 2023 12:46:59 -0900 Subject: [PATCH] attempt to fix scroll behavior --- frontend/app/router.options.ts | 14 -------------- frontend/components/Chart/Line.vue | 1 - frontend/nuxt.config.ts | 1 - frontend/pages/items.vue | 2 -- frontend/plugins/scroll.client.ts | 7 +++++++ 5 files changed, 7 insertions(+), 18 deletions(-) delete mode 100644 frontend/app/router.options.ts create mode 100644 frontend/plugins/scroll.client.ts diff --git a/frontend/app/router.options.ts b/frontend/app/router.options.ts deleted file mode 100644 index e650b3f..0000000 --- a/frontend/app/router.options.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { RouterConfig } from "@nuxt/schema"; - -export default { - scrollBehavior(to, from, savedPosition) { - console.log(to, from, savedPosition); - if (savedPosition) { - return savedPosition; - } else { - return { - top: 0, - }; - } - }, -}; diff --git a/frontend/components/Chart/Line.vue b/frontend/components/Chart/Line.vue index c74e759..c36ef93 100644 --- a/frontend/components/Chart/Line.vue +++ b/frontend/components/Chart/Line.vue @@ -56,7 +56,6 @@ const calcWidth = ref(0); function resize() { - console.log("resize", el.value?.offsetHeight, el.value?.offsetWidth); calcHeight.value = el.value?.offsetHeight || 0; calcWidth.value = el.value?.offsetWidth || 0; } diff --git a/frontend/nuxt.config.ts b/frontend/nuxt.config.ts index cba18a2..482fc05 100644 --- a/frontend/nuxt.config.ts +++ b/frontend/nuxt.config.ts @@ -13,5 +13,4 @@ export default defineNuxtConfig({ }, }, css: ["@/assets/css/main.css"], - plugins: [], }); diff --git a/frontend/pages/items.vue b/frontend/pages/items.vue index 4c570bc..3b8ff3d 100644 --- a/frontend/pages/items.vue +++ b/frontend/pages/items.vue @@ -39,8 +39,6 @@ const hasNext = computed(() => page.value * pageSize.value < total.value); const hasPrev = computed(() => page.value > 1); - const itemsTitle = ref(); - function prev() { page.value = Math.max(1, page.value - 1); } diff --git a/frontend/plugins/scroll.client.ts b/frontend/plugins/scroll.client.ts new file mode 100644 index 0000000..4ecfa99 --- /dev/null +++ b/frontend/plugins/scroll.client.ts @@ -0,0 +1,7 @@ +export default defineNuxtPlugin(nuxtApp => { + nuxtApp.hook("page:finish", () => { + console.log(document.body); + document.body.scrollTo({ top: 0 }); + console.log("page:finish"); + }); +});