diff --git a/client/src/components/Chapter.vue b/client/src/components/Chapter.vue index 9121a302..c2ee9385 100644 --- a/client/src/components/Chapter.vue +++ b/client/src/components/Chapter.vue @@ -83,6 +83,7 @@ import CHAPTER_QUERY from '@/graphql/gql/queries/chapterQuery.gql'; import { getMe } from '@/mixins/me'; import { useMutation } from '@vue/apollo-composable'; import { useRoute } from 'vue-router'; +import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts'; export interface Props { chapter: Chapter; @@ -103,7 +104,7 @@ onMounted(() => { setTimeout(() => { const rect = element.getBoundingClientRect(); window.scrollTo({ top: rect.y, behavior: 'smooth' }); - }, 750); + }, PAGE_LOAD_TIMEOUT); } } }); diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue index 02862171..4b869f27 100644 --- a/client/src/components/ContentBlock.vue +++ b/client/src/components/ContentBlock.vue @@ -120,6 +120,7 @@ import DELETE_CONTENT_BLOCK_MUTATION from '@/graphql/gql/mutations/deleteContent import type { ContentBlock } from '@/@types'; import type { Modal } from '@/plugins/modal.types'; +import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts'; export interface Props { contentBlock: ContentBlock; @@ -219,7 +220,7 @@ onMounted(() => { setTimeout(() => { const rect = element.getBoundingClientRect(); window.scrollTo({ top: rect.y, behavior: 'smooth' }); - }, 750); + }, PAGE_LOAD_TIMEOUT); } } }); diff --git a/client/src/consts/navigation.consts.ts b/client/src/consts/navigation.consts.ts new file mode 100644 index 00000000..837e4f64 --- /dev/null +++ b/client/src/consts/navigation.consts.ts @@ -0,0 +1 @@ +export const PAGE_LOAD_TIMEOUT = 750; diff --git a/client/src/router/index.js b/client/src/router/index.js index a3f91f0a..7358638a 100644 --- a/client/src/router/index.js +++ b/client/src/router/index.js @@ -12,6 +12,7 @@ import { LAYOUT_SIMPLE } from '@/router/core.constants'; import { EMAIL_NOT_VERIFIED_STATE, NO_VALID_LICENSE_STATE, SUCCESS_STATE } from './oauth.names'; import start from '@/pages/start'; +import { PAGE_LOAD_TIMEOUT } from '@/consts/navigation.consts'; const instrument = () => import(/* webpackChunkName: "instruments" */ '@/pages/instrument'); const instrumentOverview = () => import(/* webpackChunkName: "instruments" */ '@/pages/instrumentOverview'); @@ -110,7 +111,11 @@ const router = createRouter({ mode: 'history', scrollBehavior(to, from, savedPosition) { if (savedPosition) { - return savedPosition; + return new Promise((resolve) => { + setTimeout(() => { + resolve(savedPosition); + }, PAGE_LOAD_TIMEOUT); + }); } return { left: 0, top: 0 }; },