$('.main-slider').on('init', function(event, slick) {
$('.main-slider').find('.slick-current').removeClass('slick-active').addClass('reset-animation');
setTimeout( function() {
$('.main-slider').find('.slick-current').removeClass('reset-animation').addClass('slick-active');
}, 1);
});
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', vh + 'px');
window.addEventListener('resize', function () {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', vh + 'px');
});
// ¸ÞÀÎ ºñÁÖ¾ó ½½¶óÀÌ´õ
$('.main-slider').slick({
fade:true,
slidesToShow: 1,
draggable:true,
speed:1200,
lazyLoad: false,
autoplay: true,
dots: true,
autoplaySpeed:4000,
pauseOnFocus:false,
pauseOnHover:false,
pauseOnDotsHover:false,
pauseOnArrowsHover:false,
appendArrows:$('.arrow-con > .arrows'),
prevArrow:'',
nextArrow:'',
});
$('.main-slider').on('touchstart', e => {
$('.main-slider').slick('slickPlay');
});
// PROJECT ½½¶óÀÌ´õ
$('.single-item').slick({
dots: false,
slidesToShow: 3,
speed: 1000,
autoplay: false,
autoplaySpeed: 1600,
lazyLoad: false,
pauseOnFocus:false,
pauseOnHover:false,
arrows: true,
responsive: [
{
breakpoint: 961, //È¸é »çÀÌÁî 960px
settings: {
slidesToShow:2
}
},
{
breakpoint: 481, //È¸é »çÀÌÁî 480px
settings: {
slidesToShow:1
}
}
]
});
$('.footer-select').on('click','.placeholder',function(){
var parent = $(this).closest('.footer-select');
if ( ! parent.hasClass('is-open')){
parent.addClass('is-open');
$('.footer-select.is-open').not(parent).removeClass('is-open');
}else{
parent.removeClass('is-open');
}
}).on('click','ul>li',function(){
var parent = $(this).closest('.footer-select');
parent.removeClass('is-open').find('.placeholder').text( $(this).text() );
});
// --------------------------------------------------------------------------------------------- //
"use strict";
// Çì´õ gnb ½ºÅ©¸³Æ®
const header = document.querySelector('.header');
const mobileGnb = document.querySelector('.mobile-gnb');
window.addEventListener('DOMContentLoaded', () => {
initGnb(header);
initMobileGnb(mobileGnb);
})
// PC
function initGnb(header){
let gnb = header.querySelector('.header-gnb');
let gnbMenus = gnb.querySelectorAll('.gnb-depth-1 .depth-1');
let depthMenus = gnb.querySelectorAll('.gnb-depth-2');
let maxHeight = calculateMaxHeight();
if (window.innerWidth > 1024) {
changeMenuHeight(maxHeight);
}
gnb.addEventListener('mouseenter', (event) => {
gnbOpen(header);
});
gnb.addEventListener('focusin', (event) => {
gnbOpen(header);
});
gnb.addEventListener('mouseleave', (event) => {
gnbClose(header);
});
gnb.addEventListener('focusout', (event) => {
gnbClose(header);
});
gnbMenus.forEach(menu => {
menu.addEventListener('mouseenter', (event) => {
menu.classList.add('current');
});
menu.addEventListener('focusin', (event) => {
menu.classList.add('current');
});
menu.addEventListener('mouseleave', (event) => {
menu.classList.remove('current');
});
menu.addEventListener('focusout', (event) => {
menu.classList.remove('current');
});
});
window.addEventListener('resize', function(){
if (window.innerWidth > 1024) {
maxHeight = calculateMaxHeight();
changeMenuHeight(maxHeight);
}
});
function gnbOpen(header){
let headerHeight = maxHeight + 90; // 90Àº Çì´õ¹ÙÀÇ ³ôÀÌ
header.style.height = `${headerHeight}px`;
header.classList.add('open');
}
function gnbClose(header){
header.classList.remove('open');
header.removeAttribute("style");
}
function calculateMaxHeight(){
let heights = [...depthMenus].map((item) => item.getBoundingClientRect().height);
let maxHeight = Math.max.apply(null, heights);
return maxHeight;
}
function changeMenuHeight(height) {
depthMenus.forEach(item => {
item.style.height = `${height}px`;
});
}
}
// Mobile
function initMobileGnb(mobileGnb){
let html = document.querySelector('html');
let sidebarButton = mobileGnb.querySelector('.sidebar-btn');
let mobileMenuButtons = mobileGnb.querySelectorAll('.depth-1 a');
sidebarButton.addEventListener('click', (event) => {
if (mobileGnb.classList.contains('open')) {
mobileGnbClose(mobileGnb);
} else {
mobileGnbOpen(mobileGnb);
}
});
mobileMenuButtons.forEach(button => {
button.addEventListener('click', (event) => {
const button = event.target.closest('.depth-1-link');
if (!button) return;
if (siblings(button).length > 0) event.preventDefault();
openAccordion(button);
});
})
window.addEventListener('resize', function(){
if (window.innerWidth > 1024) {
mobileGnbClose(mobileGnb);
}
});
function mobileGnbOpen(gnb){
gnb.classList.add('open');
html.classList.add('not-scroll');
}
function mobileGnbClose(gnb){
gnb.classList.remove('open');
html.classList.remove('not-scroll');
}
// ¸ð¹ÙÀÏ ¸Þ´º ¾ÆÄÚµð¾ð
function openAccordion($this) {
console.log($this);
let target = $this.parentElement;
let depthTarget = $this.nextElementSibling;
if (!depthTarget) return;
let otherLinks = siblings(target);
let otherItems = otherLinks.map(link => link.querySelector('ul'));
if (target.classList.contains('open')){
target.classList.remove('open');
depthTarget.style.maxHeight = '0px';
} else {
otherLinks.forEach(link => link.classList.remove('open'));
otherItems.forEach(item => item ? item.style.maxHeight = '0px' : '');
target.classList.add('open');
depthTarget.style.maxHeight = depthTarget.scrollHeight + 'px';
}
}
}
function siblings(element) {
return [...element.parentElement.children].filter(value => value != element);
}