//========================================================
// アニメーション
//========================================================
$(function () {
setTimeout(function () {
$('.first-view').addClass('is-animation');
},1000);
});
$(window).on('load scroll', function () {
isAnimation();
});
function isAnimation() {
$('.js-animation').each(function () {
var win_scroll = $(window).scrollTop();
var win_height = $(window).height();
var scroll_pos = win_scroll + win_height;
if ($(this).offset().top < scroll_pos) {
$(this).addClass('is-animation');
}
});
}
//========================================================
// スライダー用スクリプト
//========================================================
$(function () {
$('.lf-hero-slider-a-inner').slick({
appendArrows: $('.lf-hero-slider-a-arrows'),
autoplay: true,
autoplaySpeed: 5000,
dots: true
});
$('.lyt-slider-lf-a-inner').slick({
accessibility: true,
infinite: true,
arrows: true,
dots: true,
slidesToShow: 3,
slidesToScroll: 3,
appendArrows: $('.lyt-slider-lf-a-arrows'),
appendDots: $('.lyt-slider-lf-a-dots'),
responsive: [{
breakpoint: 1280,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
$('.lyt-slider-lf-b-inner').slick({
accessibility: true,
infinite: true,
arrows: true,
slidesToShow: 3,
slidesToScroll: 3,
appendArrows: $('.lyt-slider-lf-b-arrows'),
appendDots: $('.lyt-slider-lf-b-dots'),
responsive: [{
breakpoint: 1280,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
//========================================================
// SVG icon
//========================================================
$(function () {
var svgIcon = '';
$('.btn-lf-a').prepend(svgIcon);
});
//========================================================
// 高さ揃えスクリプト
//========================================================
// ウィンドウ幅の判定
function checkDeviceType() {
var width = window.innerWidth;
if (width > 767) {
return 'pc';
} else if (width > 1) {
return 'sp'
} else {
return 'zero';
}
}
// 現在の画面で定義したブレイクポイントと一致するか判定
function matchHtmlDataBreakpoint(device, breakpoint) {
if (breakpoint === 'zero') {
if (device === 'zero') {
return false;
} else {
return true;
}
} else if (breakpoint === 'sp') {
if (device === 'zero' || device === 'sp') {
return false;
} else {
return true;
}
}
}
// htmlのData属性からブレイクポイントを取得
function getHtmlDataBreakpoint(num) {
var breakpoint = $('#js-align-height-breakpoint-sp' + num);
if (!breakpoint.length) {
return 'sp';
}
return 'zero';
}
// 高さをそろえたい要素のグループを取得
function getClassList() {
var elements = $('[class*="js-align-height-box"]'),
classList = [],
className;
elements.each(function (index, element) {
className = element.getAttribute('class').match(/js-align-height-box[0-9]+/);
if (!className) {
return;
}
if (classList.indexOf('.' + className[0]) >= 0) {
return;
} else {
classList.push('.' + className[0]);
}
});
return classList;
}
// 高さ調整スクリプト
// 取得した中で一番高い高さを付与する
function matchHeight() {
var elementsGroup = getClassList(), // 高さを揃えたいグループのクラスを取得する
maxHeight = 0, //一番高さのある要素の高さ
boxHeight = 0, //要素の高さ
device = checkDeviceType(), //sp
breakpoint, //高さを揃える際のブレイクポイント
needClearMaxHeight; //高さのクリアが必要な
elementsGroup.forEach(function (elements) {
$(elements).css('height', 'auto');
if (elements.match(/[0-9]+/) != null) {
breakpoint = getHtmlDataBreakpoint(elements.match(/[0-9]+/)[0]);
} else {
return;
}
needClearMaxHeight = matchHtmlDataBreakpoint(device, breakpoint);
if (!needClearMaxHeight) {
return;
}
// 高さの比較
$(elements).each(function (index, element) {
boxHeight = $(element).outerHeight();
if (index === 0) {
maxHeight = boxHeight;
} else if (maxHeight < boxHeight) {
maxHeight = boxHeight;
}
});
// 要素にmaxHeightを指定
$(elements).css('height', maxHeight + 'px');
});
};
window.addEventListener('load', function () {
matchHeight();
});
window.addEventListener('resize', function () {
setTimeout(function () {
matchHeight();
//ウィンドウサイズがリサイズされたときに、高さ調整スクリプトを起動する
}, 500);
});
// DOMの読み込みが完了したら発火
window.addEventListener("DOMContentLoaded",function(){
// 全ての「.js-height-max」を「elem」に代入
var elem = document.getElementsByClassName("js-height-max");
// 「h_list」にElementsの高さの配列を代入
var h_list = getHeight(elem);
// 「h_list」の中で最も大きい値を算出し代入
h_list = Math.max.apply(null, h_list);
if(!_ua.Mobile && !_ua.Tablet){
setHeight(elem,h_list);
}
},false);
// 最も大きい値を各Elementsに付与
function setHeight(target,h){
for(var h_i = 0;h_i a.contact").attr("target", "_blank");
})(jQuery);