Orientation change doesn't get detected

I’m having issues with orientation change detection in Phaser 3.

scene.scale.on('orientationchange', function(orientation) {
    // this doesn't get called on mobile...

The function above fires when playing on desktop browsers with dev tools simulating mobile devices. Rotate is detected just fine.

However, on mobile devices, it never got called.
Is this a bug? Is there any other way to detect orientation?

have you seen this example? looks working well on my mobile device

Hi @Darko,

Thank you for your answer.
That’s weird… that example didn’t work on my mobile devices either.
As stated here, it seems to be a bug indeed.
That page also referred to your example.

I have found a solution though.

window.onresize = function (){
   if(window.innerWidth > window.innerHeight){
     // landscape
     // portrait

Now it works well across all my devices.


Keep in mind that window.innerWidth and windor.InnerHeight might not be the same when changing the orientation, ex: on chrome on iOS then you have to use the outherWidth instead of inner