scroll...

This commit is contained in:
tamaina 2023-07-18 04:39:56 +00:00
parent 054ea30955
commit fd44a29f2b
2 changed files with 18 additions and 1 deletions

View file

@ -41,7 +41,7 @@
import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue'; import { computed, ComputedRef, isRef, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, watch } from 'vue';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import * as os from '@/os'; 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 { useDocumentVisibility } from '@/scripts/use-document-visibility';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
@ -428,6 +428,10 @@ function visibilityChange() {
timerForSetPause.value = window.setTimeout(() => { timerForSetPause.value = window.setTimeout(() => {
isPausingUpdate.value = true; isPausingUpdate.value = true;
timerForSetPause.value = null; timerForSetPause.value = null;
if (!backed) {
scrollBy(scrollableElement, { top: 16, behavior: 'instant' });
backed = true;
}
}, },
BACKGROUND_PAUSE_WAIT_SEC * 1000); BACKGROUND_PAUSE_WAIT_SEC * 1000);
} else { // 'visible' } else { // 'visible'

View file

@ -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 * Scroll to Top
* @param el Scroll container element * @param el Scroll container element