aboutsummaryrefslogtreecommitdiffstats
path: root/src/fx.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-02-09 15:58:12 +0000
committerJohn Resig <jeresig@gmail.com>2009-02-09 15:58:12 +0000
commit0ae78024c23dd3ef4bcea883338d975dcf843597 (patch)
tree467358774b053e307dbf47a3aaa916c05e16d685 /src/fx.js
parent136a459f4c24880f6d07f26c07e56451385637e0 (diff)
downloadjquery-0ae78024c23dd3ef4bcea883338d975dcf843597.tar.gz
jquery-0ae78024c23dd3ef4bcea883338d975dcf843597.zip
Added a performance improvement to .hide()/.show() that helps to prevent constant reflows from occurring. Fixes #4038.
Diffstat (limited to 'src/fx.js')
-rw-r--r--src/fx.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/fx.js b/src/fx.js
index 39456e031..3d00515ff 100644
--- a/src/fx.js
+++ b/src/fx.js
@@ -44,7 +44,13 @@ jQuery.fn.extend({
elemdisplay[ tagName ] = display;
}
- this[i].style.display = jQuery.data(this[i], "olddisplay", display);
+ jQuery.data(this[i], "olddisplay", display);
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var i = 0, l = this.length; i < l; i++ ){
+ this[i].style.display = jQuery.data(this[i], "olddisplay");
}
}
@@ -60,8 +66,14 @@ jQuery.fn.extend({
var old = jQuery.data(this[i], "olddisplay");
if ( !old && old !== "none" )
jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ }
+
+ // Set the display of the elements in a second loop
+ // to avoid the constant reflow
+ for ( var i = 0, l = this.length; i < l; i++ ){
this[i].style.display = "none";
}
+
return this;
}
},