window.addEventListener("load", function() { new Swiper("#swiper_1", { speed: 600, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', } }); scrollInit(); }); // 맨 위로 버튼 $(document).on("click", "#btnMoveTop", function () { $("html, body").animate({scrollTop: 0}, "fast"); }); let header = document.getElementsByTagName("header")[0]; let nav = document.getElementsByTagName("nav")[0]; let headerHeight = header.offsetHeight; let navHeight = nav.offsetHeight; window.onscroll = function () { scrollInit(); }; function scrollInit() { let windowTop = window.scrollY; let footHeight = document.getElementsByTagName("footer")[0].offsetTop; if (windowTop >= (headerHeight + navHeight)) { header.classList.add("position-fixed"); nav.classList.add("position-fixed"); }else{ header.classList.remove("position-fixed"); nav.classList.remove("position-fixed"); } if((windowTop + window.innerHeight) > footHeight) { $("#btnMoveTop").css("position", "absolute"); }else{ $("#btnMoveTop").css("position", "fixed"); } }