Revert "fix(frontend): scroll error (#112)"

This reverts commit b6d9894ed9.
This commit is contained in:
まっちゃとーにゅ 2023-07-25 02:35:38 +09:00
parent d1202ab39a
commit 31e7fc391e
No known key found for this signature in database
GPG key ID: 6AFBBF529601C1DB
2 changed files with 13 additions and 10 deletions

View file

@ -128,7 +128,7 @@ const moreFetching = ref(false);
const more = ref(false); const more = ref(false);
const preventAppearFetchMore = ref(false); const preventAppearFetchMore = ref(false);
const preventAppearFetchMoreTimer = ref<number | null>(null); const preventAppearFetchMoreTimer = ref<number | null>(null);
const isActive = ref(false); const isBackTop = ref(false);
const empty = computed(() => items.value.size === 0); const empty = computed(() => items.value.size === 0);
const error = ref(false); const error = ref(false);
const { const {
@ -167,8 +167,8 @@ watch($$(rootEl), () => {
}); });
}); });
watch([$$(backed), $$(contentEl)], (n, o) => { watch([$$(backed), $$(contentEl)], () => {
if (!backed && isActive.value) { if (!backed) {
if (!contentEl) return; if (!contentEl) return;
scrollRemove = (props.pagination.reversed ? onScrollBottom : onScrollTop)(contentEl, executeQueue, TOLERANCE); scrollRemove = (props.pagination.reversed ? onScrollBottom : onScrollTop)(contentEl, executeQueue, TOLERANCE);
@ -339,7 +339,7 @@ const appearFetchMoreAhead = async (): Promise<void> => {
fetchMoreAppearTimeout(); fetchMoreAppearTimeout();
}; };
const isTop = (): boolean => isActive.value && (props.pagination.reversed ? isBottomVisible : isTopVisible)(contentEl!, TOLERANCE); const isTop = (): boolean => isBackTop.value || (props.pagination.reversed ? isBottomVisible : isTopVisible)(contentEl!, TOLERANCE);
watch(visibility, () => { watch(visibility, () => {
if (visibility.value === 'hidden') { if (visibility.value === 'hidden') {
@ -431,11 +431,11 @@ const updateItem = (id: MisskeyEntity['id'], replacer: (old: MisskeyEntity) => M
const inited = init(); const inited = init();
onActivated(() => { onActivated(() => {
isActive.value = true; isBackTop.value = false;
}); });
onDeactivated(() => { onDeactivated(() => {
isActive.value = false; isBackTop.value = props.pagination.reversed ? window.scrollY >= (rootEl ? rootEl.scrollHeight - window.innerHeight : 0) : window.scrollY === 0;
}); });
function toBottom() { function toBottom() {

View file

@ -1,7 +1,7 @@
// NIRAX --- A lightweight router // NIRAX --- A lightweight router
import { EventEmitter } from 'eventemitter3'; import { EventEmitter } from 'eventemitter3';
import { Component, nextTick, onMounted, shallowRef, ShallowRef } from 'vue'; import { Component, onMounted, shallowRef, ShallowRef } from 'vue';
import { safeURIDecode } from '@/scripts/safe-uri-decode'; import { safeURIDecode } from '@/scripts/safe-uri-decode';
type RouteDef = { type RouteDef = {
@ -284,9 +284,12 @@ export function useScrollPositionManager(getScrollContainer: () => HTMLElement,
router.addListener('change', ctx => { router.addListener('change', ctx => {
const scrollPos = scrollPosStore.get(ctx.key) ?? 0; const scrollPos = scrollPosStore.get(ctx.key) ?? 0;
nextTick(() => {
scrollContainer.scroll({ top: scrollPos, behavior: 'instant' }); scrollContainer.scroll({ top: scrollPos, behavior: 'instant' });
}); if (scrollPos !== 0) {
window.setTimeout(() => { // 遷移直後はタイミングによってはコンポーネントが復元し切ってない可能性も考えられるため少し時間を空けて再度スクロール
scrollContainer.scroll({ top: scrollPos, behavior: 'instant' });
}, 100);
}
}); });
router.addListener('same', () => { router.addListener('same', () => {