aboutsummaryrefslogtreecommitdiff
path: root/FrontEnd/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-05-13 16:15:10 +0800
committercrupest <crupest@outlook.com>2021-05-13 16:15:10 +0800
commitdf481624ca4c145318a19c088fce3db326dc0a64 (patch)
treec65c5d798216ede459a5748a294b15636f245f6d /FrontEnd/src
parentf21b031f7fab34b1c7cbe92cad37109d3e52b938 (diff)
downloadtimeline-df481624ca4c145318a19c088fce3db326dc0a64.tar.gz
timeline-df481624ca4c145318a19c088fce3db326dc0a64.tar.bz2
timeline-df481624ca4c145318a19c088fce3db326dc0a64.zip
...
Diffstat (limited to 'FrontEnd/src')
-rw-r--r--FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts9
-rw-r--r--FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx13
2 files changed, 5 insertions, 17 deletions
diff --git a/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts b/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
index 42894c20..c381dac2 100644
--- a/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
+++ b/FrontEnd/src/app/utilities/useReverseScrollPositionRemember.ts
@@ -16,10 +16,11 @@ export function getReverseScrollPosition(): number {
export function scrollToReverseScrollPosition(reversePosition: number): void {
if (document.documentElement.scrollHeight <= window.innerHeight) return;
- document.documentElement.scrollTop =
- document.documentElement.scrollHeight -
- window.innerHeight -
- reversePosition;
+
+ window.scrollTo(
+ 0,
+ document.documentElement.scrollHeight - window.innerHeight - reversePosition
+ );
}
let scrollPosition = getReverseScrollPosition();
diff --git a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
index 9c43434d..69fd9207 100644
--- a/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
+++ b/FrontEnd/src/app/views/timeline-common/TimelinePagedPostListView.tsx
@@ -3,11 +3,6 @@ import { fromEvent } from "rxjs";
import { HttpTimelinePostInfo } from "@/http/timeline";
-import {
- getReverseScrollPosition,
- scrollToReverseScrollPosition,
-} from "@/utilities/useReverseScrollPositionRemember";
-
import TimelinePostListView from "./TimelinePostListView";
export interface TimelinePagedPostListViewProps {
@@ -30,18 +25,10 @@ const TimelinePagedPostListView: React.FC<TimelinePagedPostListViewProps> = (
: posts.slice(-lastViewCount);
}, [posts, lastViewCount]);
- const lastScrollPosition = React.useRef<number | null>(null);
-
React.useEffect(() => {
- if (lastScrollPosition.current != null) {
- scrollToReverseScrollPosition(lastScrollPosition.current);
- lastScrollPosition.current = null;
- }
-
if (lastViewCount < posts.length) {
const subscription = fromEvent(window, "scroll").subscribe(() => {
if (window.scrollY === 0) {
- lastScrollPosition.current = getReverseScrollPosition();
setLastViewCount(lastViewCount + 10);
}
});