//hamburgerBtn_menu $(".hamburgerBtn").on("click", function () { $(this).toggleClass("js-active"); $("body").toggleClass("js-fixed"); $(".gnav").toggleClass("js-active"); }); $(".gnav__item._normal a").on("click", function () { $("body").removeClass("js-fixed"); $(".hamburgerBtn").removeClass("js-active"); $(".gnav").removeClass("js-active"); }); //sp_navi_accodion $('.gnav__btn').on("click",function() { $(this).toggleClass('js-open'); $(this).next().slideToggle(); return false; }); //sp_non_hover $(function () { var touch = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; if (touch) { try { for (var si in document.styleSheets) { var styleSheet = document.styleSheets[si]; if (!styleSheet.rules) continue; for (var ri = styleSheet.rules.length - 1; ri >= 0; ri--) { if (!styleSheet.rules[ri].selectorText) continue; if (styleSheet.rules[ri].selectorText.match(':hover')) { styleSheet.deleteRule(ri); } } } } catch (ex) {} } }); // logo const fvHeight = $('#fv').outerHeight(); const utHeight = $('#underTitle').outerHeight(); const header = $('.header'); const headerUnder = $('.header._under'); const headerInner = $('.header__inner'); const haderModal = $('.header__modal'); $(window).scroll(function() { const scrollTop = $(this).scrollTop(); if (scrollTop > fvHeight) { header.addClass("js-active"); headerUnder.addClass("js-active"); headerInner.addClass("js-active"); haderModal.addClass("js-active"); } else { header.removeClass("js-active"); headerUnder.removeClass("js-active"); headerInner.removeClass("js-active"); haderModal.removeClass("js-active"); }; if (scrollTop > utHeight) { headerUnder.addClass("js-active"); } else { headerUnder.removeClass("js-active"); }; }); //to_top let topBtn = $('.btnTop'); topBtn.hide(); $(window).scroll(function () { let height = 500; let fvHeight = $(".fv").height(); if ($(this).scrollTop() >= fvHeight || $(this).scrollTop() >= height) { topBtn.fadeIn(); } else { topBtn.fadeOut(); } }); topBtn.click(function () { $('body,html').animate({ scrollTop: 0 }); return false; }); //MW_WP_Form_error $(".form-row").each(function() { if ($(this).find("span.error").length == 1) { $(this).addClass("js-error"); } }); // yubinbango_add-class $( '.mw_wp_form form' ).attr( 'class', 'h-adr' ); //100vh const setFillHeight = () => { const vh = window.innerHeight * 0.01; document.documentElement.style.setProperty('--vh', `${vh}px`); } window.addEventListener('resize', setFillHeight); setFillHeight(); //inview $(function () { $(".js-fadeUp, .js-fadeUp2, .js-fadeUp3").on("inview", function () { $(this).addClass("js-inview"); }); }); //image_size const myFunc = function (src) { return new Promise(function(resolve, reject){ const image = new Image(); image.src = src; image.onload = function(){ resolve(image); } image.onerror = function(error){ reject(error); } }); } const imgs = document.getElementsByTagName('img'); for (const img of imgs) { const src = img.getAttribute('src'); myFunc(src) .then(function(res){ let width = res.width; let height = res.height; if (!img.hasAttribute('width')) { if (src.toLowerCase().endsWith('.svg')) { img.setAttribute('width', width); } else { width = Math.round(width / 2); if (width % 2 !== 0) { width += 1; } img.setAttribute('width', width); } } if (!img.hasAttribute('height')) { if (src.toLowerCase().endsWith('.svg')) { img.setAttribute('height', height); } else { height = Math.round(height / 2); if (height % 2 !== 0) { height += 1; } img.setAttribute('height', height); } } }) .catch(function(error){ console.log(error); }); } //TOP_development $(function() { $('.topProducts__imgList').first().find('.topProducts__imgItem').first().addClass('current'); $('.topProducts__imgItem').hover(function() { const imgSrc = $(this).find('img').attr('src'); $('.topProducts__imgMain img').attr('src', imgSrc); $('.topProducts__imgItem.current').removeClass('current'); $(this).addClass('current'); $('.topProducts__img').addClass('opacity'); $('.topProducts__img').on('animationend', function() { $(this).removeClass('opacity'); }); }); $('.topProducts__imgBtnLeft, .topProducts__imgBtnRight').on('click', function() { const $currentItem = $('.topProducts__imgItem.current'); const currentItemNumber = parseInt($currentItem.attr('data-nember')); let $targetItem; if ($(this).hasClass('topProducts__imgBtnLeft')) { const prevItemNumber = (currentItemNumber - 1 + 9) % 9; $targetItem = $(`.topProducts__imgItem[data-nember="${prevItemNumber}"]`); } else { const nextItemNumber = (currentItemNumber + 1) % 9; $targetItem = $(`.topProducts__imgItem[data-nember="${nextItemNumber}"]`); } if ($targetItem) { const imgSrc = $targetItem.find('img').attr('src'); $('.topProducts__imgMain img').attr('src', imgSrc); $('.topProducts__imgItem.current').removeClass('current'); $targetItem.addClass('current'); $('.topProducts__img').addClass('opacity'); $('.topProducts__img').on('animationend', function() { $(this).removeClass('opacity'); }); } }); //volume-on_off $(function () { const video = $("video").get(0); const fvMusic = $(".fv__music"); fvMusic.on("click", function () { if (video.muted) { video.muted = false; fvMusic.addClass("js-active"); } else { video.muted = true; fvMusic.removeClass("js-active"); } }); }); // TAB_menu $(function () { $(".news__list:first-of-type").css("display", "block"); $(".news__tabItem").on("click", function () { event.preventDefault(); $(".current").removeClass("current"); $(this).addClass("current"); const index = $(this).index(); $(".news__list").hide().eq(index).fadeIn(300); }); }); });