cache window dimensions

This commit is contained in:
Adam Bradley
2015-09-13 22:34:23 -05:00
parent dc1c997f52
commit 28c8d001e6
12 changed files with 33 additions and 36 deletions

View File

@@ -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 = {};
}