diff --git a/src/widgets/navigation/footer.tsx b/src/widgets/navigation/footer.tsx index 9bcdc2e..6ef2b43 100644 --- a/src/widgets/navigation/footer.tsx +++ b/src/widgets/navigation/footer.tsx @@ -101,9 +101,13 @@ export const FooterNavigation = ({ if (!tabbar) return; const TABBAR_HEIGHT = 70; + const SAFE_AREA_BOTTOM = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--sab')) || 34; + const TOTAL_HIDE_HEIGHT = TABBAR_HEIGHT + SAFE_AREA_BOTTOM; const SCROLL_THRESHOLD = 50; const SNAP_THRESHOLD = 0.5; // 50% 보이면 표시, 아니면 숨김 - const SCROLL_MULTIPLIER = 0.5; // 스크롤의 50%만큼 이동 + const SCROLL_MULTIPLIER = 0.8; // 스크롤의 80%만큼 이동 + + console.log('TABBAR_HEIGHT:', TABBAR_HEIGHT, 'SAFE_AREA_BOTTOM:', SAFE_AREA_BOTTOM, 'TOTAL_HIDE_HEIGHT:', TOTAL_HIDE_HEIGHT); let lastScrollY = 0; let currentTranslateY = 0; // 별도로 추적 @@ -124,33 +128,16 @@ export const FooterNavigation = ({ } // 스크롤 방향에 따라 translateY 조정 - if (currentScrollY > SCROLL_THRESHOLD) { - // 스크롤 다운 - if (scrollDelta > 0) { - currentTranslateY = Math.min(currentTranslateY + scrollDelta * SCROLL_MULTIPLIER, TABBAR_HEIGHT); - } - // 스크롤 업 - else { - currentTranslateY = Math.max(currentTranslateY + scrollDelta * SCROLL_MULTIPLIER, 0); - } - - tabbar.style.transform = `translateY(${currentTranslateY}px)`; - - // opacity 계산 (0 = 완전히 보임, TABBAR_HEIGHT = 완전히 숨김) - const opacityRatio = 1 - (currentTranslateY / TABBAR_HEIGHT); - const buttons = tabbar.querySelectorAll('.tab-button') as NodeListOf; - buttons.forEach(button => { - button.style.opacity = `${Math.max(0.1, opacityRatio)}`; - }); - } else { - // 페이지 상단 근처에서는 완전히 표시 - currentTranslateY = 0; - tabbar.style.transform = 'translateY(0)'; - const buttons = tabbar.querySelectorAll('.tab-button') as NodeListOf; - buttons.forEach(button => { - button.style.opacity = '1'; - }); + // 스크롤 다운 + if (scrollDelta > 0) { + currentTranslateY = Math.min(currentTranslateY + scrollDelta * SCROLL_MULTIPLIER, TOTAL_HIDE_HEIGHT); } + // 스크롤 업 + else { + currentTranslateY = Math.max(currentTranslateY + scrollDelta * SCROLL_MULTIPLIER, 0); + } + + tabbar.style.transform = `translateY(${currentTranslateY}px)`; lastScrollY = currentScrollY; ticking = false; @@ -165,7 +152,7 @@ export const FooterNavigation = ({ isScrolling = false; // 현재 위치 확인 후 snap - const visibleRatio = 1 - (currentTranslateY / TABBAR_HEIGHT); + const visibleRatio = 1 - (currentTranslateY / TOTAL_HIDE_HEIGHT); tabbar.classList.add('snapping'); @@ -173,18 +160,10 @@ export const FooterNavigation = ({ // 50% 이상 보이면 완전히 표시 currentTranslateY = 0; tabbar.style.transform = 'translateY(0)'; - const buttons = tabbar.querySelectorAll('.tab-button') as NodeListOf; - buttons.forEach(button => { - button.style.opacity = '1'; - }); } else { // 50% 미만이면 완전히 숨김 - currentTranslateY = TABBAR_HEIGHT; - tabbar.style.transform = `translateY(${TABBAR_HEIGHT}px)`; - const buttons = tabbar.querySelectorAll('.tab-button') as NodeListOf; - buttons.forEach(button => { - button.style.opacity = '0.1'; - }); + currentTranslateY = TOTAL_HIDE_HEIGHT; + tabbar.style.transform = `translateY(${TOTAL_HIDE_HEIGHT}px)`; } }, 150); };