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/innerHeightpull/21833/head
parent
7123abc122
commit
525e3eaf43
|
@ -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 New Issue