Skip to content

Commit

Permalink
cache for size of objects out of dom
Browse files Browse the repository at this point in the history
  • Loading branch information
felipevex committed Oct 16, 2018
1 parent 4e9d3ef commit 1f36b63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion priori/app/PriApp.hx
Expand Up @@ -89,7 +89,7 @@ class PriApp extends PriGroup {

this.frame = Browser.document.createDivElement();
this.frame.className = "priori_stylebase";
this.frame.style.cssText = "overflow:visible;width:1000px;height:1000px;left:-1000px;top:1000px;";
this.frame.style.cssText = "overflow:visible;width:1000px;height:1000px;visibility:hidden;";
Browser.window.document.body.appendChild(this.frame);

this.dispatchEvent(new PriEvent(PriEvent.ADDED_TO_APP, true));
Expand Down
10 changes: 10 additions & 0 deletions priori/view/PriDisplay.hx
@@ -1,5 +1,6 @@
package priori.view;

import haxe.ds.StringMap;
import priori.app.PriApp;
import helper.browser.BrowserHandler;
import helper.display.DisplayHelperIgnition;
Expand Down Expand Up @@ -344,11 +345,20 @@ class PriDisplay extends PriEventDispatcher {
return result;
}

static private var OUTER_DOM_SIZE_CACHE:StringMap<PriGeomBox> = new StringMap<PriGeomBox>();

private function getOutDOMDimensions():PriGeomBox {

var code:String = this.dh.jselement.outerHTML;

if (OUTER_DOM_SIZE_CACHE.exists(code)) return OUTER_DOM_SIZE_CACHE.get(code);

PriApp.g().frame.innerHTML = this.dh.jselement.outerHTML;

var box:PriGeomBox = DomHelper.getBoundingClientRect(PriApp.g().frame.getElementsByTagName("div")[0]);

OUTER_DOM_SIZE_CACHE.set(code, box);

return box;
}

Expand Down

0 comments on commit 1f36b63

Please sign in to comment.