diff options
author | crupest <crupest@outlook.com> | 2020-06-10 00:40:32 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-10 00:40:32 +0800 |
commit | 0ec545e1bfee5bd6ebd7db8176bf44ba5b67bfbe (patch) | |
tree | 0651086163c3c2a3ea3d68954dc8973cab63865e /Timeline | |
parent | 5de8d90be2ddfa43c355aa13e9e8162490e4cc96 (diff) | |
download | timeline-0ec545e1bfee5bd6ebd7db8176bf44ba5b67bfbe.tar.gz timeline-0ec545e1bfee5bd6ebd7db8176bf44ba5b67bfbe.tar.bz2 timeline-0ec545e1bfee5bd6ebd7db8176bf44ba5b67bfbe.zip |
Finally one.
Diffstat (limited to 'Timeline')
-rw-r--r-- | Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx b/Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx index 8fc3815b..1cd772c2 100644 --- a/Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx +++ b/Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx @@ -1,7 +1,7 @@ import React from 'react';
import { Spinner } from 'reactstrap';
import { useTranslation } from 'react-i18next';
-import { Subject } from 'rxjs';
+import { Subject, fromEvent } from 'rxjs';
import { getAlertHost } from '../common/alert-service';
@@ -74,17 +74,23 @@ export default function TimelinePageTemplateUI< }, [resizeSubject]);
React.useEffect(() => {
- let jumpToBottom = true;
- const timerTag = window.setTimeout(() => {
- jumpToBottom = false;
- }, 1000);
- const subscription = resizeSubject.subscribe(() => {
- if (jumpToBottom)
- window.scrollTo(0, document.body.getBoundingClientRect().height);
- });
+ let scrollToBottom = true;
+ const disableScrollToBottom = (): void => {
+ scrollToBottom = false;
+ };
+
+ const subscriptions = [
+ fromEvent(window, 'wheel').subscribe(disableScrollToBottom),
+ fromEvent(window, 'pointerdown').subscribe(disableScrollToBottom),
+ resizeSubject.subscribe(() => {
+ if (scrollToBottom) {
+ window.scrollTo(0, document.body.scrollHeight);
+ }
+ }),
+ ];
+
return () => {
- clearTimeout(timerTag);
- subscription.unsubscribe();
+ subscriptions.forEach((s) => s.unsubscribe());
};
}, [resizeSubject, timeline, props.posts]);
|