// h5-orientation-listener
(function () {
function handleOrientationChange() {
var isPortrait = window.innerHeight > window.innerWidth;
var container = document.getElementById("Cocos2dGameContainer");
if (!container) return;
if (isPortrait) {
container.style.transform = "rotate(90deg)";
container.style.transformOrigin = "center center";
container.style.width = window.innerHeight + "px";
container.style.height = window.innerWidth + "px";
container.style.position = "absolute";
container.style.top = "50%";
container.style.left = "50%";
container.style.marginTop = -(window.innerWidth / 2) + "px";
container.style.marginLeft = -(window.innerHeight / 2) + "px";
} else {
container.style.transform = "none";
container.style.width = "100%";
container.style.height = "100%";
container.style.position = "absolute";
container.style.top = "0";
container.style.left = "0";
container.style.marginTop = "0";
container.style.marginLeft = "0";
}
if (window.cc && cc.view) {
cc.view.setCanvasSize(window.innerWidth, window.innerHeight);
}
}
window.addEventListener("orientationchange", function () {
setTimeout(handleOrientationChange, 300);
});
window.addEventListener("resize", handleOrientationChange);
window.addEventListener("load", function () {
setTimeout(handleOrientationChange, 500);
});
})();