/* ---------- js ---------- */ jQuery(function ($) { /* 모바일 메뉴 열기 */ function mNav_open() { $(".btn-nav").addClass("mNav_open"); $("#header .navWrap").addClass("mNav_open"); $(".gnbMenuBg").fadeIn(); } function mNav_close() { $(".btn-nav").removeClass("mNav_open"); $("#header .navWrap").removeClass("mNav_open"); $(".gnbMenuBg").fadeOut(); } $(".btn-nav").click(function () { if (!$(this).hasClass("mNav_open")) { mNav_open(); } else { mNav_close(); } }); $(".gnbMenuBg,.mobile-header-close,.navWrap .gnb > li > a,.header-go-to-top").click(function () { mNav_close(); }); $('.navWrap ul.gnb li a[href*="#"]').click(function (e) { if ($(this).attr('href') != '#') { e.preventDefault(); } }); $(window).resize(function () { if ($(window).width() > 991) { mNav_close(); }; }); $(window).scroll(function () { if ($(this).scrollTop() > 150) $('.go-to-top').fadeIn('slow'); else $('.go-to-top').fadeOut('slow'); }); $('.header-go-to-top').click(function () { $("html, body").animate({ scrollTop: 0 }, 500); return false; }); $('.go-to-top').click(function () { $("html, body").animate({ scrollTop: 0 }, 500); return false; }); }); jQuery(function ($) { // init Isotope var initial_items = 8; var next_items = 4; var $grid = $('.portfolio-grid').isotope({ itemSelector: '.element-item', layoutMode: 'masonry', stamp: '.element-item--static' }); function showNextItems(pagination) { var itemsCount = 0; $('.visible_item').each(function () { if (itemsCount < pagination) { $(this).removeClass('visible_item'); itemsCount++; } }); $grid.isotope('layout'); } function hideItems(pagination) { var itemsCount = 0; $('.tabArea > .tabBox.on .element-item').each(function () { if (itemsCount >= pagination) { $(this).addClass('visible_item'); } itemsCount++; }); $grid.isotope('layout'); } $('.tabArea .tabBox.on .showMore').on('click', function (e) { e.preventDefault(); showNextItems(next_items); }); hideItems(initial_items); $(".tabArea .tab li a").on("click", function (e) { // 해당 요소를 클릭하는 내 자신의 index 번호를 가져온다. [0], [1] e.preventDefault(); const num = $(".tabArea .tab li a").index($(this)); // 기존에 적용되어 있는 on class 삭제 $(".tabArea .tab li").removeClass("on"); $(".tabArea .tabBox").removeClass("on"); // 다음 요소 클릭시 on class 추가 $('.tabArea .tab li:eq(' + num + ')').addClass("on"); $('.tabArea .tabBox:eq(' + num + ')').addClass("on"); function showNextItems1(pagination) { var itemsCount = 0; $('.tabArea .tabBox:eq(' + num + ')').find('.visible_item').each(function () { if (itemsCount < pagination) { $(this).removeClass('visible_item'); itemsCount++; } }); $grid.isotope('layout'); } function hideItems1(pagination) { var itemsCount = 0; $('.tabArea .tabBox:eq(' + num + ')').find('.element-item').each(function () { if (itemsCount >= pagination) { $(this).addClass('visible_item'); } itemsCount++; }); $grid.isotope('layout'); } $('.tabBox.on .showMore').on('click', function (e) { e.preventDefault(); showNextItems1(next_items); }); hideItems1(initial_items); }); });