customize.js
//スムーススクロール
/*$(function () {
var adjust_anchor = function () {
var urlHash = $(location).attr('hash');
if (urlHash) {
var speed = 10;
var target = $(urlHash == "#" || urlHash == "" ? 'html' : urlHash);
var position = target.offset().top;
// スムーススクロール
$('body,html').animate({
scrollTop: position
}, speed, 'swing');
return false;
}
};
setTimeout(adjust_anchor, 500);
$('a[href^="#"]').click(function (e) {
var href = $(this).attr("href");
var target = $(href == "#" || href == "" ? 'html' : href);
var position = target.offset().top;
$.when(
$("html, body").animate({
scrollTop: position
}, 400, "swing"),
e.preventDefault(),
).done(function () {
var diff = target.offset().top;
if (diff === position) {} else {
$("html, body").animate({
scrollTop: diff
}, 10, "swing");
}
});
});
});*/
//スムーススクロール
$(function () {
var headerHeight = $(".header").height();
var adjust_anchor = function () {
var urlHash = $(location).attr("hash");
if (urlHash) {
var speed = 200;
var target = $(urlHash == "#" || urlHash == "" ? "html" : urlHash);
var position = target.offset().top - headerHeight;
// スムーススクロール
$("body,html").animate({
scrollTop: position
}, speed, "swing");
return false;
}
};
setTimeout(adjust_anchor, 500);
$('a[href*="#"]').click(function (e) {
var click_elm = $(this);
var href = $(this).attr("href");
var hash_position = href.indexOf('#');
href = href.substring(hash_position);
var target = $(href == "#" || href == "" ? "html" : href);
var position = target.offset().top - headerHeight;
//console.log("scroll");
$.when(
$("html, body").animate({
scrollTop: position,
}, 400, "swing"),
e.preventDefault()
).done(function () {
var diff = target.offset().top - headerHeight;
if (diff === position) {} else {
click_elm.click();
}
});
});
});
/* 画像切り替え-pcとsp- */
$(function () {
var $setElem = $('.switch'),
pcName = '_pc',
spName = '_sp',
replaceWidth = 641;
$setElem.each(function () {
var $this = $(this);
function imgSize() {
var windowWidth = parseInt($(window).width());
if (windowWidth >= replaceWidth) {
$this.attr('src', $this.attr('src').replace(spName, pcName)).css({
visibility: 'visible'
});
} else if (windowWidth < replaceWidth) {
$this.attr('src', $this.attr('src').replace(pcName, spName)).css({
visibility: 'visible'
});
}
}
$(window).resize(function () {
imgSize();
});
imgSize();
});
});
/* 画像切り替え-pcとtabとsp- */
$(function () {
var $setElem = $('.switch2'),
pcName = '_pc',
tbName = '_tb',
spName = '_sp',
replaceWidthTb = 1025,
replaceWidthSp = 361;
$setElem.each(function () {
var $this = $(this);
function imgSize() {
var windowWidth = parseInt($(window).width());
if (windowWidth >= replaceWidthTb) {
$this.attr('src', $this.attr('src').replace(spName, pcName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(tbName, pcName)).css({
visibility: 'visible'
});
} else if (windowWidth < replaceWidthTb && windowWidth > replaceWidthSp) {
$this.attr('src', $this.attr('src').replace(pcName, tbName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(spName, tbName)).css({
visibility: 'visible'
});
} else if (windowWidth < replaceWidthSp) {
$this.attr('src', $this.attr('src').replace(pcName, spName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(tbName, spName)).css({
visibility: 'visible'
});
}
}
$(window).resize(function () {
imgSize();
});
imgSize();
});
});
/* 画像切り替え-pcとtabとsp-2 */
$(function () {
var $setElem = $('.switch3'),
pcName = '_pc',
tbName = '_tb',
spName = '_sp',
replaceWidthTb = 768,
replaceWidthSp = 361;
$setElem.each(function () {
var $this = $(this);
function imgSize() {
var windowWidth = parseInt($(window).width());
if (windowWidth >= replaceWidthTb) {
$this.attr('src', $this.attr('src').replace(spName, pcName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(tbName, pcName)).css({
visibility: 'visible'
});
} else if (windowWidth < replaceWidthTb && windowWidth > replaceWidthSp) {
$this.attr('src', $this.attr('src').replace(pcName, tbName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(spName, tbName)).css({
visibility: 'visible'
});
} else if (windowWidth < replaceWidthSp) {
$this.attr('src', $this.attr('src').replace(pcName, spName)).css({
visibility: 'visible'
});
$this.attr('src', $this.attr('src').replace(tbName, spName)).css({
visibility: 'visible'
});
}
}
$(window).resize(function () {
imgSize();
});
imgSize();
});
});
/* CTAをフォーム位置から消す */
$(function () {
$(window).scroll(function () {
const wHeight = $(window).height();
const scrollAmount = $(window).scrollTop();
$('#contact').each(function () {
const targetPosition = $(this).offset().top;
if (scrollAmount > targetPosition - wHeight) {
$('.cta').removeClass('slide-on');
$('.cta').addClass('slide-off');
} else {
$('.cta').removeClass('slide-off');
$('.cta').addClass('slide-on');
}
});
});
});
/* ボタンクリックで表示 */
/*$(function () {
$(".contentBtn").click(function () {
$(this).next('.content__body').slideToggle(400, "linear");
$(this).addClass('is-active');
$(this).children().children().next().next('.contentBtn__more').fadeToggle(200, "linear");
});
$(".contentBtn--reverse").click(function () {
$(this).next('.content__body').slideToggle(400, "linear");
$(this).addClass('is-active');
$(this).children().children().next().next('.contentBtn__more').fadeToggle(200, "linear");
});
$(".contentBtn__wrapper").click(function () {
$(this).addClass('is-active');
});
});*/
$(function () {
$(window).load(function () {
var a01 = $("#a01").offset().top;
var a02 = $("#a02").offset().top;
var a03 = $("#a03").offset().top;
var a04 = $("#a04").offset().top;
var a05 = $("#a05").offset().top;
var a06 = $("#a06").offset().top;
var a07 = $("#a07").offset().top;
$(window).on('scroll', function () {
var scrollPos = $(window).scrollTop();
var headerHeight = $(".header").height();
if (scrollPos >= a01 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec01 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a05 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec05 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a02 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec02 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a03 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec03 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a04 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec04 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a06 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec06 .header__menu-list__item__link").addClass("active");
}
if (scrollPos >= a07 - headerHeight - 10) {
$(".header__menu-list__item__link").removeClass("active");
$("#g-sec07 .header__menu-list__item__link").addClass("active");
}
});
});
});
/*$(function () {
$('.header__menu-list__item__link').on('click', function () {
$('.header__menu-list__item__link').not(this).removeClass('active');
$(this).addClass('active');
});
});*/
//メール相談クリック時
/*$(function () {
$('.cmn-contact__form__link.mail').click(function () {
$('.form').addClass('is-active').fadeIn(300, "linear");
});
});*/
//LINE相談クリック時
/*$(function () {
$('.cmn-contact__form__link.line').click(function () {
$('#page_line-contact').addClass('is-active').fadeIn(300, "linear");
});
$('.header__line').click(function () {
$('#page_line-contact').addClass('is-active').fadeIn(300, "linear");
});
});*/
$(function () {
$('.area01').hide();
$('.area02').hide();
$('div [class^="type-"]').on('click', function () {
$('.area > div').not($('#' + $(this).attr('class'))).hide(); // クリックした要素の class と違うID名のセクションを非表示
$('#' + $(this).attr('class')).show(); // クリックした要素の class と同じIDのセクションを表示
});
});