+ 2
Can anyone explain me why window width at orientation angle 0 is 640 and at angle 90 it is 360 for android device?
window.addEventListener("orientationchange", function(){ console.log("the orientation of the device is now " + screen.orientation.angle+"and width is"+this.innerWidth); });
2 odpowiedzi
+ 2
The orientationchange event is triggered before the screen size changes.
https://code.sololearn.com/Wx9WSk1iLP36/?ref=app
You can get the correct output using onresize or setting a timeOut in your orientationchange function to wait for screen resizing.
+ 1
Thank you Kevin Star