italia2024
Version:
Italia 2024 assets
30 lines (24 loc) • 970 B
JavaScript
(function () {
//determ-attrStyle.js
let arrDetermHs = Array.prototype.slice.call(document.querySelectorAll(".js-determ-h")); //Arr.NodeList
//ウィンドウロード・リサイズ・スクロール時のイベント
var timerVEZA = 0;
let fnDetermHgt = function () {
if (timerVEZA) clearTimeout(timerVEZA);
timerVEZA = setTimeout(() => {
for (let n = 0; n < arrDetermHs.length; n++) {
let elmDetermH = arrDetermHs[n];
//要素の現在のheightをリセット
elmDetermH.style.height = '';
//要素の実際のheightを取得
let height = elmDetermH.getBoundingClientRect().height - 1;
//要素にheightを設定
elmDetermH.style.height = height + 'px';
}
}, 300); //delayTime
};
//ウィンドウロード・リサイズ・スクロール時のイベント呼び出し
['load', 'resize', 'scroll'].forEach((event) => {
window.addEventListener(event, fnDetermHgt);
});
})();