phaser icon indicating copy to clipboard operation
phaser copied to clipboard

Event "orientationchange" not fired on iPad

Open pfdtravalmatic opened this issue 7 years ago • 5 comments

Version

  • Phaser Version: 3.16.2 experimental (f62ec4a73969a6c8e4168e0568e9e592ce8d65c9)
  • Operating system: iOS 12.1.4 on iPad
  • Browsers: Chrome, Safari

Description

The event "orientationchange" is never fired on an iPad device using the following line:

this.game.scale.on("orientationchange", ()=>{ alert("test"); });

Also occurs in the example. The message "Please set your phone to landscape" is displayed regardless of orientation.

However,

window.addEventListener('orientationchange', ()=>{ alert("test"); });

works fine.

pfdtravalmatic avatar Feb 13 '19 13:02 pfdtravalmatic

Doesn't work either in iPhone 5S with ios 10.3.3.

The problem seems to be in ScaleManager.js. I'm still tracking the bug apparently for some reason this._checkOrientation remains false and ScaleManager.updateOrientation() doesn't run.

EDIT: Not only this._checkOrientation remains false the first time it executes, but also newOrientation is always returning undefined.

var newOrientation = GetScreenOrientation(this.width, this.height);

EDIT 2: Annnd.... the problem is that GetScreenOrientation() is using CONST.PORTRAIT and CONST.LANDSCAPE instead of CONST.ORIENTATION.PORTRAIT / CONST.ORIENTATION.LANDSCAPE.

Another solution could be to require

var CONST = require('../scale/const/ORIENTATION_CONST');

Currently its requiring

var CONST = require('../scale/const');

EDIT 3: Now another issue that is happening in ios, there is a window.screen object that reports the screen size, but when you are in landscape mode, screen.height remains being the height of the phone screen, not the height of the viewport, so this check fails because screen.height will always be greater than screen.width:


if (screen) {
        return (screen.height > screen.width) ? CONST.PORTRAIT : CONST.LANDSCAPE;
}

jackfreak avatar Mar 25 '19 14:03 jackfreak

any news about this?

doing test in browserstack on different devices the result is doesn't work in all iphone devices

Doesn't work either in iPhone 5S with ios 10.3.3.

The problem seems to be in ScaleManager.js. I'm still tracking the bug apparently for some reason this._checkOrientation remains false and ScaleManager.updateOrientation() doesn't run.

EDIT: Not only this._checkOrientation remains false the first time it executes, but also newOrientation is always returning undefined.

var newOrientation = GetScreenOrientation(this.width, this.height);

EDIT 2: Annnd.... the problem is that GetScreenOrientation() is using CONST.PORTRAIT and CONST.LANDSCAPE instead of CONST.ORIENTATION.PORTRAIT / CONST.ORIENTATION.LANDSCAPE.

Another solution could be to require

var CONST = require('../scale/const/ORIENTATION_CONST');

Currently its requiring

var CONST = require('../scale/const');

EDIT 3: Now another issue that is happening in ios, there is a window.screen object that reports the screen size, but when you are in landscape mode, screen.height remains being the height of the phone screen, not the height of the viewport, so this check fails because screen.height will always be greater than screen.width:


if (screen) {
        return (screen.height > screen.width) ? CONST.PORTRAIT : CONST.LANDSCAPE;
}

murilorrui avatar Jul 16 '19 18:07 murilorrui

No solution yet to this? This doesn't only impact Safari, I can reproduce the same behaviour in Edge on iOS (iPhone 11 Pro) as well.

johanlindfors avatar Mar 03 '20 06:03 johanlindfors

This issue has been mentioned on Phaser. There might be relevant details there:

https://phaser.discourse.group/t/orientation-change-doesnt-get-detected/6488/3

photonstorm avatar May 29 '20 11:05 photonstorm

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

photonstorm avatar Sep 11 '20 14:09 photonstorm