Can anyone explain me why window width at orientation angle 0 is 640 and at angle 90 it is 360 for android device? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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); });

13th May 2020, 9:34 PM
Abhay
Abhay - avatar
2 Answers
+ 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.
13th May 2020, 10:17 PM
Kevin ★
+ 1
Thank you Kevin Star
13th May 2020, 10:25 PM
Abhay
Abhay - avatar