Permalink
Browse files

Reduce reflows by hiding from DOM,

 instead of removing an element immediately.
  • Loading branch information...
1 parent 3d424b0 commit b19e37de6e25d094ceebff60a5828588fc2389e9 @vizanto vizanto committed Feb 5, 2014
Showing with 7 additions and 2 deletions.
  1. +7 −2 prime-display/src/prime/js/display/DisplayList.hx
@@ -19,16 +19,21 @@ class DisplayList
{
if (object.elem.parentNode != target.elem)
{
- target.elem.appendChild(object.elem);
+ if (object.elem.parentNode != null) object.elem.parentNode.removeChild(object.elem);
+ object.style.display = "block";
object.parent = target;
+ target.elem.appendChild(object.elem);
}
}
public #if !noinline inline #end function remove(object:DOMElem)
{
if (object.elem.parentNode == target.elem)
{
- target.elem.removeChild(object.elem);
+ // --- Reduce reflows by hiding from DOM, instead of removing an element immediately:
+ //target.elem.removeChild(object.elem);
+ // ---
+ object.style.display = "none";
object.parent = null;
}
}

0 comments on commit b19e37d

Please sign in to comment.