26 lines
680 B
JavaScript
26 lines
680 B
JavaScript
|
(function(){
|
||
|
function bindEvent(type){
|
||
|
return (data)=>{
|
||
|
const e = new Event(type);
|
||
|
e.data = data;
|
||
|
window.dispatchEvent(e);
|
||
|
}
|
||
|
}
|
||
|
const event_trigger = bindEvent("hadSetRem")
|
||
|
function remCurrent(){
|
||
|
const clientWidth=document.documentElement.clientWidth;
|
||
|
let fontSize = clientWidth / 19.2 +'px';
|
||
|
if(clientWidth<=750){
|
||
|
fontSize = clientWidth / 7.5 + 'px';
|
||
|
}else if(750<clientWidth&&clientWidth<=1920){
|
||
|
fontSize=clientWidth / 19.2 +'px';
|
||
|
}
|
||
|
document.documentElement.style.fontSize = fontSize;
|
||
|
}
|
||
|
window.addEventListener('resize',remCurrent)
|
||
|
remCurrent()
|
||
|
setTimeout(()=>{
|
||
|
event_trigger(true)
|
||
|
},1000)
|
||
|
})()
|