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:
parent
7123abc122
commit
525e3eaf43
1 changed files with 3 additions and 1 deletions
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in a new issue