MMOBILE-3833 core: Fix watchOrientation in iOS 12

main
Dani Palou 2022-01-26 07:57:42 +01:00
parent 4ecab6d3f1
commit 1ba9f4ac8e
1 changed files with 7 additions and 2 deletions

View File

@ -121,11 +121,16 @@ export class CoreScreenService {
*/
watchOrientation(): void {
// Listen media orientation CSS queries.
window.matchMedia('(orientation: portrait)').addEventListener('change', (m) => {
const changeListener = (m: MediaQueryListEvent) => {
const orientation = m.matches ? CoreScreenOrientation.PORTRAIT : CoreScreenOrientation.LANDSCAPE;
CoreEvents.trigger(CoreEvents.ORIENTATION_CHANGE, { orientation });
});
};
const mql = window.matchMedia('(orientation: portrait)');
mql.addEventListener ?
mql.addEventListener('change', changeListener) :
mql.addListener(changeListener);
}
/**