fix: Remove animation when scrolling pages with script

This commit is contained in:
haitaoo
2023-06-02 16:51:40 +08:00
parent 151fe851d3
commit 979fb120d1
5 changed files with 12 additions and 9 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import {
installBaseInfo,
checkConfigFileExists,
} from '@/services';
import { Storage, handleFormError } from '@/utils';
import { Storage, handleFormError, scrollToDocTop } from '@/utils';
import { CURRENT_LANG_STORAGE_KEY } from '@/common/constants';
import {
@@ -109,7 +109,7 @@ const Index: FC = () => {
};
const handleErr = (data) => {
window.scrollTo(0, 0);
scrollToDocTop();
setErrorData(data);
};
+3 -3
View File
@@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next';
import { Pagination, CustomSidebar } from '@/components';
import { loggedUserInfoStore, toastStore } from '@/stores';
import { scrollToElementTop } from '@/utils';
import { scrollToElementTop, scrollToDocTop } from '@/utils';
import { usePageTags, usePageUsers } from '@/hooks';
import type {
ListResult,
@@ -158,7 +158,7 @@ const Index = () => {
return;
}
if (type === 'default') {
window.scrollTo(0, 0);
scrollToDocTop();
getDetail();
return;
}
@@ -183,7 +183,7 @@ const Index = () => {
if (!qid) {
return;
}
window.scrollTo(0, 0);
scrollToDocTop();
getDetail();
requestAnswers();
}, [qid]);
+2 -1
View File
@@ -7,6 +7,7 @@ import { usePageTags } from '@/hooks';
import { BaseUserCard, FormatTime, Empty, DiffContent } from '@/components';
import { getReviewList, revisionAudit } from '@/services';
import { pathFactory } from '@/router/pathFactory';
import { scrollToDocTop } from '@/utils';
import type * as Type from '@/common/interface';
const Index: FC = () => {
@@ -39,7 +40,7 @@ const Index: FC = () => {
setNoTasks(true);
}
setTimeout(() => {
window.scrollTo({ top: 0 });
scrollToDocTop();
}, 150);
};
const queryNextOne = (pageNumber) => {
+2 -2
View File
@@ -19,7 +19,7 @@ import {
} from '@/services';
import QuestionList, { QUESTION_ORDER_KEYS } from '@/components/QuestionList';
import HotQuestions from '@/components/HotQuestions';
import { escapeRemove, guard, Storage } from '@/utils';
import { escapeRemove, guard, Storage, scrollToDocTop } from '@/utils';
import { pathFactory } from '@/router/pathFactory';
import { QUESTIONS_ORDER_STORAGE_KEY } from '@/common/constants';
@@ -60,7 +60,7 @@ const Index: FC = () => {
useEffect(() => {
if (!listLoading) {
window.scrollTo(0, 0);
scrollToDocTop();
}
}, [listLoading]);
+3 -1
View File
@@ -36,6 +36,7 @@ function scrollToElementTop(element) {
window.scrollTo({
top: offsetPosition,
behavior: 'instant' as ScrollBehavior,
});
}
@@ -43,7 +44,8 @@ const scrollToDocTop = () => {
setTimeout(() => {
window.scrollTo({
top: 0,
behavior: 'smooth',
left: 0,
behavior: 'instant' as ScrollBehavior,
});
});
};