Prevent reflow when getting screen orientation

It is better to access the device orientation using media queries as it will not force a reflow compared to accessing innerWidth/innerHeight
This commit is contained in:
Germain Souquet 2021-05-25 09:46:49 +01:00
parent 7123abc122
commit 525e3eaf43

View file

@ -684,7 +684,9 @@ export default class CountlyAnalytics {
}
private getOrientation = (): Orientation => {
return window.innerWidth > window.innerHeight ? Orientation.Landscape : Orientation.Portrait;
return window.matchMedia("(orientation: landscape)").matches
? Orientation.Landscape
: Orientation.Portrait
};
private reportOrientation = () => {