Fortunately, window.orientation is already updated when the onorientationchange event is fired. Therefore, as a workaround, I include the following:
switch(window.orientation) { case 90: case -90: // portrait; h = Math.max(window.innerWidth, window.innerHeight); w = Math.min(window.innerWidth, window.innerHeight); break; default: // landscape h = Math.min(window.innerWidth, window.innerHeight); w = Math.max(window.innerWidth, window.innerHeight); break; }
Not perfect, but it works.
source share