From fd44a29f2b013f70be4f365d31315a20a89d3715 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 18 Jul 2023 04:39:56 +0000 Subject: [PATCH] scroll... --- packages/frontend/src/components/MkPagination.vue | 6 +++++- packages/frontend/src/scripts/scroll.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index 8adcccc82..191fc449f 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -41,7 +41,7 @@ import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue'; import * as misskey from 'misskey-js'; import * as os from '@/os'; -import { isBottomVisible, isTopVisible, getBodyScrollHeight, getScrollContainer, scrollToBottom, scrollToTop, scroll } from '@/scripts/scroll'; +import { isBottomVisible, isTopVisible, getScrollContainer, scrollToBottom, scrollToTop, scrollBy } from '@/scripts/scroll'; import { useDocumentVisibility } from '@/scripts/use-document-visibility'; import MkButton from '@/components/MkButton.vue'; import { defaultStore } from '@/store'; @@ -428,6 +428,10 @@ function visibilityChange() { timerForSetPause.value = window.setTimeout(() => { isPausingUpdate.value = true; timerForSetPause.value = null; + if (!backed) { + scrollBy(scrollableElement, { top: 16, behavior: 'instant' }); + backed = true; + } }, BACKGROUND_PAUSE_WAIT_SEC * 1000); } else { // 'visible' diff --git a/packages/frontend/src/scripts/scroll.ts b/packages/frontend/src/scripts/scroll.ts index 94f5757b3..f34f5aff5 100644 --- a/packages/frontend/src/scripts/scroll.ts +++ b/packages/frontend/src/scripts/scroll.ts @@ -83,6 +83,19 @@ export function scroll(el: HTMLElement | null, options: ScrollToOptions | undefi } } +/** + * コンテナを指定してscrollByする + * @param el Container element + * @param options ScrollToOptions + */ +export function scrollBy(el: HTMLElement | null, options: ScrollToOptions | undefined) { + if (el == null) { + window.scrollBy(options); + } else { + el.scrollBy(options); + } +} + /** * Scroll to Top * @param el Scroll container element