From 31e7fc391ea904d83002c427026807d595f404e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Tue, 25 Jul 2023 02:35:38 +0900 Subject: [PATCH 1/2] Revert "fix(frontend): scroll error (#112)" This reverts commit b6d9894ed931249b3105cfbd071915b6652380da. --- packages/frontend/src/components/MkPagination.vue | 12 ++++++------ packages/frontend/src/nirax.ts | 11 +++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index 989313b18..661b04c36 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -128,7 +128,7 @@ const moreFetching = ref(false); const more = ref(false); const preventAppearFetchMore = ref(false); const preventAppearFetchMoreTimer = ref(null); -const isActive = ref(false); +const isBackTop = ref(false); const empty = computed(() => items.value.size === 0); const error = ref(false); const { @@ -167,8 +167,8 @@ watch($$(rootEl), () => { }); }); -watch([$$(backed), $$(contentEl)], (n, o) => { - if (!backed && isActive.value) { +watch([$$(backed), $$(contentEl)], () => { + if (!backed) { if (!contentEl) return; scrollRemove = (props.pagination.reversed ? onScrollBottom : onScrollTop)(contentEl, executeQueue, TOLERANCE); @@ -339,7 +339,7 @@ const appearFetchMoreAhead = async (): Promise => { 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, () => { if (visibility.value === 'hidden') { @@ -431,11 +431,11 @@ const updateItem = (id: MisskeyEntity['id'], replacer: (old: MisskeyEntity) => M const inited = init(); onActivated(() => { - isActive.value = true; + isBackTop.value = false; }); onDeactivated(() => { - isActive.value = false; + isBackTop.value = props.pagination.reversed ? window.scrollY >= (rootEl ? rootEl.scrollHeight - window.innerHeight : 0) : window.scrollY === 0; }); function toBottom() { diff --git a/packages/frontend/src/nirax.ts b/packages/frontend/src/nirax.ts index 979812c0a..3a03444de 100644 --- a/packages/frontend/src/nirax.ts +++ b/packages/frontend/src/nirax.ts @@ -1,7 +1,7 @@ // NIRAX --- A lightweight router 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'; type RouteDef = { @@ -284,9 +284,12 @@ export function useScrollPositionManager(getScrollContainer: () => HTMLElement, router.addListener('change', ctx => { 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', () => { From 13e8dbaf96b41c45ff1b8bfd491d1f57190e7b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Sat, 29 Jul 2023 04:58:44 +0900 Subject: [PATCH 2/2] Revert "enhance(frontend): Better Timeline(MkPagination) Experience (#11066)" This reverts commit 92d9946f597c2b06552b23ba370708aea86575c0. --- .../frontend/src/components/MkPagination.vue | 169 +++++------------- packages/frontend/src/pages/admin/abuses.vue | 2 +- .../src/pages/custom-emojis-manager.vue | 2 +- 3 files changed, 47 insertions(+), 126 deletions(-) diff --git a/packages/frontend/src/components/MkPagination.vue b/packages/frontend/src/components/MkPagination.vue index 661b04c36..598529bf5 100644 --- a/packages/frontend/src/components/MkPagination.vue +++ b/packages/frontend/src/components/MkPagination.vue @@ -21,14 +21,14 @@
- + {{ i18n.ts.loadMore }}
- +
- + {{ i18n.ts.loadMore }} @@ -50,7 +50,6 @@ import { i18n } from '@/i18n'; const SECOND_FETCH_LIMIT = 30; const TOLERANCE = 16; -const APPEAR_MINIMUM_INTERVAL = 600; export type Paging = { endpoint: E; @@ -72,16 +71,6 @@ export type Paging pageEl?: HTMLElement; }; - -type MisskeyEntityMap = Map; - -function arrayToEntries(entities: MisskeyEntity[]): [string, MisskeyEntity][] { - return entities.map(en => [en.id, en]); -} - -function concatMapWithArray(map: MisskeyEntityMap, entities: MisskeyEntity[]): MisskeyEntityMap { - return new Map([...map, ...arrayToEntries(entities)]); -}