diff --git a/src/components/Feed/Feed.vue b/src/components/Feed/Feed.vue index 122d4cd78..49fd4ccbf 100644 --- a/src/components/Feed/Feed.vue +++ b/src/components/Feed/Feed.vue @@ -3,7 +3,7 @@ import MediaCard from '@pages/passport/components/MediaCard.vue' import { MediaEmbed } from '@devprotocol/clubs-plugin-passports/vue' import type { PassportItemAssetType } from '@devprotocol/clubs-plugin-passports/types' import type { FeedType } from '@fixtures/api/feed' -import { computed } from 'vue' +import { computed, onMounted, ref } from 'vue' import { itemToHash } from '@fixtures/router/passportItem' const props = defineProps() @@ -12,10 +12,17 @@ const assetLink = computed( () => `/passport/${props.address}/${props.parentPassportIndex === 0 ? '' : props.parentPassport.id}?i=${itemToHash(props.clipType, props.item.id)}`, ) + +const mediaHeight = ref(0) +// PCの場合200px、スマホの場合110px +onMounted(() => { + mediaHeight.value = window.innerWidth > 768 ? 200 : 110 +}) + - + + + diff --git a/src/components/Feed/FeedPageContent.vue b/src/components/Feed/FeedPageContent.vue index a24d5d109..34dcbecf6 100644 --- a/src/components/Feed/FeedPageContent.vue +++ b/src/components/Feed/FeedPageContent.vue @@ -1,7 +1,6 @@ diff --git a/src/components/Feed/VirtualScroll.vue b/src/components/Feed/VirtualScroll.vue index d6ada15eb..14dc5687a 100644 --- a/src/components/Feed/VirtualScroll.vue +++ b/src/components/Feed/VirtualScroll.vue @@ -3,25 +3,19 @@ import { ref, computed, onMounted, watch } from 'vue' import type { FeedType } from '@fixtures/api/feed' import Feed from '@components/Feed/Feed.vue' -// プロパティの型定義 interface Props { items: T[] - itemHeight: number // アイテムの高さ - buffer: number // 表示範囲外のアイテム数 + itemHeight: number + buffer: number } -// プロパティの宣言 const props = defineProps>() -// DOM要素の参照 const container = ref(null) -// スクロール位置の保存 const scrollTop = ref(0) -// 全体の高さを計算 const totalHeight = computed(() => props.items.length * props.itemHeight) -// 可視アイテムの数を計算 const visibleCount = computed(() => { if (!container.value) return 0 return ( @@ -29,7 +23,6 @@ const visibleCount = computed(() => { ) }) -// 可視アイテムの開始インデックスを計算 const startIndex = computed(() => { return Math.max( 0, @@ -37,12 +30,10 @@ const startIndex = computed(() => { ) }) -// 可視アイテムの終了インデックスを計算 const endIndex = computed(() => { return Math.min(props.items.length, startIndex.value + visibleCount.value) }) -// 可視アイテムを計算 const visibleItems = computed(() => { return props.items .slice(startIndex.value, endIndex.value) @@ -52,7 +43,6 @@ const visibleItems = computed(() => { })) }) -// スクロールイベントハンドラ const onScroll = () => { if (container.value) { scrollTop.value = container.value.scrollTop @@ -68,14 +58,12 @@ const throttledOnScroll = () => { scrollTimeout = window.setTimeout(onScroll, 16) } -// マウント時にスクロール位置を初期化 onMounted(() => { if (container.value) { scrollTop.value = container.value.scrollTop } }) -// スクロール位置やアイテムの変更を監視 watch([scrollTop, () => props.items], () => { if (container.value) { container.value.scrollTop = scrollTop.value @@ -89,15 +77,13 @@ watch([scrollTop, () => props.items], () => { ref="container" @scroll="throttledOnScroll" > -
-