UNPKG

italia2024

Version:

Italia 2024 assets

54 lines (44 loc) 2.04 kB
(function () { //fluid-responsiveRems.js let fnDLRzVHEA = function () { //一時的なスタイルを適用する関数 function applyTempStyle(property, value) { const tempStyle = document.createElement('style'); tempStyle.textContent = `:root { ${property}: ${value} !important; }`; document.head.appendChild(tempStyle); const computedValue = getComputedStyle(document.documentElement).getPropertyValue(property); document.head.removeChild(tempStyle); return computedValue; } //Origin Font-size const originFontSize = getComputedStyle(document.documentElement).getPropertyValue('font-size'); //fch(root font-stretch) const tempfStretch = applyTempStyle('font-size', 'clamp(0.884pc, calc(0.884pc + ((1vw - 0.225pc) * 0.5875)), 1.117pc)'); //数値を抽出する関数 function fchNumbers(str) { return str.match(/[-+]?[0-9]*\.?[0-9]+/g).map(Number); } //値を抽出 const newfStretch = fchNumbers(tempfStretch) / 16 * 100; //:rootに新しい値を設定 document.documentElement.style.setProperty('font-stretch', `${newfStretch}%`); console.log('新しい値:', newfStretch); //rcap(root cap-height) const tempRcapHeight = applyTempStyle('font-size', 'clamp(0.456pc, calc(0.456pc + ((1vw - 0.225pc) * 1.36)), 1pc)'); //数値を抽出する関数 function rcapNumbers(str) { return str.match(/[-+]?[0-9]*\.?[0-9]+/g).map(Number); } //値を抽出 const newRcapHeight = rcapNumbers(tempRcapHeight) / 16; //:rootに新しい値を設定 document.documentElement.style.setProperty('font-size-adjust', `cap-height ${newRcapHeight}`); console.log('新しい値:', newRcapHeight); //Origin Font-sizeを復元 document.documentElement.style.setProperty('font-size', originFontSize); }; //ウィンドウDOMロード・リサイズ時のイベント呼び出し ['DOMContentLoaded', 'resize'].forEach((events) => { window.addEventListener(events, fnDLRzVHEA); }); })(); ///function();