fix: 쇼츠 전체 화면 창에서 영상이 화면보다 커져 확대·잘려 보이던 문제 — 남은 높이·너비 안에 9:16으로 맞추고, 영상이 뜨기 전엔 표지를 깔기

This commit is contained in:
minaChoi committed 2026-10-26 14:23:51 +09:00
1 parent b718955927
commit 8ea8c9b368
1 file changed
+9 -5
+9 -5
View File
@@ -11,6 +11,9 @@ const CARD_W = 120
const PLAYER_W = 200
const SCALE = (CARD_W / PLAYER_W) * 1.4
// 전체 화면 창의 영상 칸: 닫기 줄 아래 남은 높이와 화면 너비 안에 9:16으로 맞춘다
const FIT = { width: 'min(100vw, calc((100dvh - env(safe-area-inset-top, 0px) - 52px) * 9 / 16))', aspectRatio: '9 / 16' }
function embed(id: string, controls: boolean) {
const q = new URLSearchParams({ autoplay: '1', mute: '1', playsinline: '1', loop: '1', playlist: id, controls: controls ? '1' : '0', rel: '0', modestbranding: '1' })
return `https://www.youtube-nocookie.com/embed/${id}?${q}`
@@ -126,11 +129,12 @@ function ShortsViewer({ items, start, onClose }: { items: ShortItem[]; start: nu
<div ref={list} className="h-[calc(100dvh-env(safe-area-inset-top,0px)-52px)] snap-y snap-mandatory overflow-y-auto [scrollbar-width:none]">
{items.map((s, i) => (
<div key={s.id} data-i={i} className="relative grid h-full snap-start place-items-center">
{i === at ? (
<iframe src={embed(s.id, true)} title={s.title} allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowFullScreen className="aspect-[9/16] h-full max-w-full border-0" />
) : (
<img src={`https://i.ytimg.com/vi/${s.id}/hqdefault.jpg`} alt="" className="aspect-[9/16] h-full max-w-full object-cover opacity-60" />
)}
<div className="relative" style={FIT}>
<img src={`https://i.ytimg.com/vi/${s.id}/hqdefault.jpg`} alt="" className={cx('absolute inset-0 size-full object-cover', i !== at && 'opacity-60')} />
{i === at && (
<iframe src={embed(s.id, true)} title={s.title} allow="autoplay; encrypted-media; picture-in-picture; fullscreen" allowFullScreen className="absolute inset-0 size-full border-0" />
)}
</div>
</div>
))}
</div>