[HTML] 날짜: 2025년 6월 16일 월요일 오후 5:24:02
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
etUI.utils.ready(function () {
|
||||
console.log('document ready');
|
||||
etUI.initUI();
|
||||
// etUI.initUI();
|
||||
|
||||
// [공통] 헤더 스크롤 관련 기능
|
||||
etUI.pages.headerScroll = function () {
|
||||
@@ -253,6 +253,66 @@ etUI.utils.ready(function () {
|
||||
}
|
||||
};
|
||||
|
||||
// [공통] top 버튼
|
||||
etUI.pages.scrollTop = function () {
|
||||
const floatingEl = document.querySelector('.floating-area');
|
||||
const hasFooter = document.querySelector('.footer');
|
||||
const isFixedBtn = document.querySelector('.component-btns.fixed');
|
||||
let isVisible = false;
|
||||
|
||||
if (!floatingEl) return;
|
||||
|
||||
// 초기 숨김 상태 설정
|
||||
gsap.set(floatingEl, {
|
||||
opacity: 0,
|
||||
// scale: 0,
|
||||
pointerEvents: 'none'
|
||||
});
|
||||
|
||||
etUI.hooks.useEventListener(window, 'scroll', () => {
|
||||
const scrollY = window.scrollY;
|
||||
|
||||
// bottom 위치 설정
|
||||
if (hasFooter) {
|
||||
floatingEl.style.bottom = '72px';
|
||||
} else if (isFixedBtn) {
|
||||
floatingEl.style.bottom = '112px';
|
||||
} else {
|
||||
floatingEl.style.bottom = '';
|
||||
}
|
||||
|
||||
if (scrollY <= 0 && isVisible) {
|
||||
// 스크롤 맨 위: 숨기기
|
||||
isVisible = false;
|
||||
gsap.to(floatingEl, {
|
||||
duration: 0.4,
|
||||
opacity: 0,
|
||||
// scale: 0,
|
||||
pointerEvents: 'none',
|
||||
ease: 'power4.out'
|
||||
});
|
||||
} else if (scrollY > 0 && !isVisible) {
|
||||
// 스크롤 내림: 보이기
|
||||
isVisible = true;
|
||||
gsap.to(floatingEl, {
|
||||
duration: 0.4,
|
||||
opacity: 1,
|
||||
scale: 1,
|
||||
pointerEvents: 'auto',
|
||||
ease: 'power4.out'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 클릭 시 top으로 부드럽게 이동
|
||||
etUI.hooks.useEventListener(floatingEl, 'click', () => {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
document.fonts.ready.then(() => {
|
||||
etUI.pages.initSwitchStyleToggle();
|
||||
etUI.pages.initPriceInputComma();
|
||||
@@ -262,5 +322,6 @@ etUI.utils.ready(function () {
|
||||
etUI.pages.activeAppbarOnPath();
|
||||
etUI.pages.headerScroll();
|
||||
etUI.pages.tabButtonToggle();
|
||||
etUI.pages.scrollTop();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user