Merge branch 'hotfix/scroll-position-instruments-from-master' into develop

This commit is contained in:
Ramon Wenger 2023-03-28 15:05:50 +02:00
commit ce481f6d99
4 changed files with 11 additions and 3 deletions

View File

@ -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);
}
}
});

View File

@ -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);
}
}
});

View File

@ -0,0 +1 @@
export const PAGE_LOAD_TIMEOUT = 750;

View File

@ -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 };
},