//xuan 版面js windowheight設定給目前的外圍html:--window-inner-height:
// this syncs the window height
const syncWindowHeight = () => {
document.documentElement.style.setProperty(
"--window-inner-height",
`${window.innerHeight}px`
);
}
//更新裝置方向,為了控制CSS,因此需要新增Class
const updateLandScapeAndWidthUnder960pxClass = () => {
if (window.innerWidth > window.innerHeight && window.matchMedia("(max-width: 960px)").matches) {
document.body.classList.add('landscapeDevice');
} else {
document.body.classList.remove('landscapeDevice');
}
}
// this locks the body and remembers the scroll position
let scrollY;
syncWindowHeight();
scrollY = window.scrollY;
document.documentElement.classList.add('epubOpen');
document.documentElement.classList.add('lightBg');
window.addEventListener("resize", function () {
updateLandScapeAndWidthUnder960pxClass();
if (isAndroid && (document.getElementsByClassName("ReeditNoteView")[0].querySelector(".popup").classList.contains("popup-active") || document.getElementsByClassName("ReeditBookMarkView")[0].querySelector(".popup").classList.contains("popup-active"))) {
return;
}
syncWindowHeight();
});
window.addEventListener('orientationchange', updateLandScapeAndWidthUnder960pxClass);
updateLandScapeAndWidthUnder960pxClass();