lightlimx-website/plugins/remJs.js

26 lines
680 B
JavaScript
Raw Normal View History

2024-07-10 14:57:22 +08:00
(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)
})()