mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
cache window dimensions
This commit is contained in:
@@ -228,7 +228,7 @@ export function closest(el, selector) {
|
||||
export function getDimensions(ele) {
|
||||
if (!ele.ionicId) {
|
||||
ele.ionicId = ++ionicElementIds;
|
||||
if (ele.ionicId % 200) {
|
||||
if (ele.ionicId % 100 === 0) {
|
||||
// periodically flush dimensions
|
||||
flushDimensionCache();
|
||||
}
|
||||
@@ -245,6 +245,16 @@ export function getDimensions(ele) {
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
export function windowDimensions() {
|
||||
if (!elementDimensions.win) {
|
||||
elementDimensions.win = {
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight
|
||||
};
|
||||
}
|
||||
return elementDimensions.win;
|
||||
}
|
||||
|
||||
export function flushDimensionCache() {
|
||||
elementDimensions = {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user