diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-04-27 17:38:48 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-04-27 17:38:48 +0900 |
| commit | 14d3439a428fb4c20b020731617478ab5e8e51b7 (patch) | |
| tree | ddb56fbb6dd724f7443452916d178ba3e2ef99b4 /packages/frontend/src | |
| parent | fix(frontend): スワイプが効かないなど、不具合の元になるma... (diff) | |
| download | misskey-14d3439a428fb4c20b020731617478ab5e8e51b7.tar.gz misskey-14d3439a428fb4c20b020731617478ab5e8e51b7.tar.bz2 misskey-14d3439a428fb4c20b020731617478ab5e8e51b7.zip | |
enhance(frontend): タイムラインをスワイプで切り替えられるように
Resolve #15722
Diffstat (limited to 'packages/frontend/src')
| -rw-r--r-- | packages/frontend/src/components/global/PageWithHeader.vue | 19 | ||||
| -rw-r--r-- | packages/frontend/src/pages/timeline.vue | 61 |
2 files changed, 38 insertions, 42 deletions
diff --git a/packages/frontend/src/components/global/PageWithHeader.vue b/packages/frontend/src/components/global/PageWithHeader.vue index 2cc7979ce4..94010fc437 100644 --- a/packages/frontend/src/components/global/PageWithHeader.vue +++ b/packages/frontend/src/components/global/PageWithHeader.vue @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only <MkStickyContainer> <template #header><MkPageHeader v-model:tab="tab" v-bind="pageHeaderProps"/></template> <div :class="$style.body"> - <MkSwiper v-if="swipable" v-model:tab="tab" :tabs="props.tabs"> + <MkSwiper v-if="swipable" v-model:tab="tab" :class="$style.swiper" :tabs="props.tabs"> <slot></slot> </MkSwiper> <slot v-else></slot> @@ -24,6 +24,7 @@ import { scrollInContainer } from '@@/js/scroll.js'; import type { PageHeaderProps } from './MkPageHeader.vue'; import { useScrollPositionKeeper } from '@/use/use-scroll-position-keeper.js'; import MkSwiper from '@/components/MkSwiper.vue'; +import { useRouter } from '@/router.js'; const props = defineProps<PageHeaderProps & { reversed?: boolean; @@ -40,10 +41,18 @@ const rootEl = useTemplateRef('rootEl'); useScrollPositionKeeper(rootEl); +const router = useRouter(); + +router.useListener('same', () => { + scrollToTop(); +}); + +function scrollToTop() { + if (rootEl.value) scrollInContainer(rootEl.value, { top: 0, behavior: 'smooth' }); +} + defineExpose({ - scrollToTop: () => { - if (rootEl.value) scrollInContainer(rootEl.value, { top: 0, behavior: 'smooth' }); - }, + scrollToTop, }); </script> @@ -52,7 +61,7 @@ defineExpose({ } -.body { +.body, .swiper { min-height: calc(100cqh - (var(--MI-stickyTop, 0px) + var(--MI-stickyBottom, 0px))); } </style> diff --git a/packages/frontend/src/pages/timeline.vue b/packages/frontend/src/pages/timeline.vue index d2bf162ce5..af28d3decd 100644 --- a/packages/frontend/src/pages/timeline.vue +++ b/packages/frontend/src/pages/timeline.vue @@ -4,36 +4,32 @@ SPDX-License-Identifier: AGPL-3.0-only --> <template> -<div ref="rootEl" class="_pageScrollable"> - <MkStickyContainer> - <template #header><MkPageHeader v-model:tab="src" :displayMyAvatar="true" :actions="headerActions" :tabs="$i ? headerTabs : headerTabsWhenNotLogin"/></template> - <MkSpacer :contentMax="800"> - <MkInfo v-if="isBasicTimeline(src) && !store.r.timelineTutorials.value[src]" style="margin-bottom: var(--MI-margin);" closable @close="closeTutorial()"> - {{ i18n.ts._timelineDescription[src] }} - </MkInfo> - <MkPostForm v-if="prefer.r.showFixedPostForm.value" :class="$style.postForm" class="_panel" fixed style="margin-bottom: var(--MI-margin);"/> - <div v-if="queue > 0" :class="$style.new"><button class="_buttonPrimary" :class="$style.newButton" @click="top()">{{ i18n.ts.newNoteRecived }}</button></div> - <MkTimeline - ref="tlComponent" - :key="src + withRenotes + withReplies + onlyFiles + withSensitive" - :class="$style.tl" - :src="src.split(':')[0]" - :list="src.split(':')[1]" - :withRenotes="withRenotes" - :withReplies="withReplies" - :withSensitive="withSensitive" - :onlyFiles="onlyFiles" - :sound="true" - @queue="queueUpdated" - /> - </MkSpacer> - </MkStickyContainer> -</div> +<PageWithHeader ref="pageComponent" v-model:tab="src" :actions="headerActions" :tabs="$i ? headerTabs : headerTabsWhenNotLogin" :swipable="true" :displayMyAvatar="true"> + <MkSpacer :contentMax="800"> + <MkInfo v-if="isBasicTimeline(src) && !store.r.timelineTutorials.value[src]" style="margin-bottom: var(--MI-margin);" closable @close="closeTutorial()"> + {{ i18n.ts._timelineDescription[src] }} + </MkInfo> + <MkPostForm v-if="prefer.r.showFixedPostForm.value" :class="$style.postForm" class="_panel" fixed style="margin-bottom: var(--MI-margin);"/> + <div v-if="queue > 0" :class="$style.new"><button class="_buttonPrimary" :class="$style.newButton" @click="top()">{{ i18n.ts.newNoteRecived }}</button></div> + <MkTimeline + ref="tlComponent" + :key="src + withRenotes + withReplies + onlyFiles + withSensitive" + :class="$style.tl" + :src="src.split(':')[0]" + :list="src.split(':')[1]" + :withRenotes="withRenotes" + :withReplies="withReplies" + :withSensitive="withSensitive" + :onlyFiles="onlyFiles" + :sound="true" + @queue="queueUpdated" + /> + </MkSpacer> +</PageWithHeader> </template> <script lang="ts" setup> import { computed, watch, provide, useTemplateRef, ref, onMounted, onActivated } from 'vue'; -import { scrollInContainer } from '@@/js/scroll.js'; import type { Tab } from '@/components/global/MkPageHeader.tabs.vue'; import type { MenuItem } from '@/types/menu.js'; import type { BasicTimelineType } from '@/timelines.js'; @@ -51,20 +47,11 @@ import { deepMerge } from '@/utility/merge.js'; import { miLocalStorage } from '@/local-storage.js'; import { availableBasicTimelines, hasWithReplies, isAvailableBasicTimeline, isBasicTimeline, basicTimelineIconClass } from '@/timelines.js'; import { prefer } from '@/preferences.js'; -import { useRouter } from '@/router.js'; -import { useScrollPositionKeeper } from '@/use/use-scroll-position-keeper.js'; provide('shouldOmitHeaderTitle', true); const tlComponent = useTemplateRef('tlComponent'); -const rootEl = useTemplateRef('rootEl'); - -useScrollPositionKeeper(rootEl); - -const router = useRouter(); -router.useListener('same', () => { - top(); -}); +const pageComponent = useTemplateRef('pageComponent'); type TimelinePageSrc = BasicTimelineType | `list:${string}`; @@ -132,7 +119,7 @@ function queueUpdated(q: number): void { } function top(): void { - if (rootEl.value) scrollInContainer(rootEl.value, { top: 0, behavior: 'instant' }); + if (pageComponent.value) pageComponent.value.scrollToTop(); } async function chooseList(ev: MouseEvent): Promise<void> { |