mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-25 07:34:45 +00:00
committed by
Nicolas Gallagher
parent
379da30e4c
commit
59af091fdb
@@ -45,8 +45,14 @@ const dimensions = {
|
||||
};
|
||||
const listeners = {};
|
||||
|
||||
let shouldInit = canUseDOM;
|
||||
|
||||
export default class Dimensions {
|
||||
static get(dimension: DimensionKey): DisplayMetrics {
|
||||
if (shouldInit) {
|
||||
shouldInit = false;
|
||||
Dimensions._update();
|
||||
}
|
||||
invariant(dimensions[dimension], `No dimension set for key ${dimension}`);
|
||||
return dimensions[dimension];
|
||||
}
|
||||
@@ -118,6 +124,5 @@ export default class Dimensions {
|
||||
}
|
||||
|
||||
if (canUseDOM) {
|
||||
Dimensions._update();
|
||||
window.addEventListener('resize', Dimensions._update, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user