aboutsummaryrefslogtreecommitdiff
path: root/Timeline
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-06-10 00:40:32 +0800
committercrupest <crupest@outlook.com>2020-06-10 00:40:32 +0800
commit5f9f27fd7001df347ab65e0cba849e583db31dc8 (patch)
tree1e9ae3c794a3f5d147152f26d2df362241c47bfc /Timeline
parent0fd5c2026e266a8bf5f120cdd21b4cd5a5bae755 (diff)
downloadtimeline-5f9f27fd7001df347ab65e0cba849e583db31dc8.tar.gz
timeline-5f9f27fd7001df347ab65e0cba849e583db31dc8.tar.bz2
timeline-5f9f27fd7001df347ab65e0cba849e583db31dc8.zip
Finally one.
Diffstat (limited to 'Timeline')
-rw-r--r--Timeline/ClientApp/src/timeline/TimelinePageTemplateUI.tsx28
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]);