Keep track of a hiding state for toggle based animations - Fixes #8685

Closes gh-1018
This commit is contained in:
Corey Frang
2012-11-07 19:23:24 -06:00
parent 781a5c0b78
commit c45f6095f2
2 changed files with 54 additions and 1 deletions

11
src/effects.js vendored
View File

@@ -234,7 +234,7 @@ jQuery.Animation = jQuery.extend( Animation, {
function defaultPrefilter( elem, props, opts ) {
/*jshint validthis:true */
var index, prop, value, length, dataShow, tween, hooks, oldfire,
var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
anim = this,
style = elem.style,
orig = {},
@@ -308,6 +308,7 @@ function defaultPrefilter( elem, props, opts ) {
value = props[ index ];
if ( rfxtypes.exec( value ) ) {
delete props[ index ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
continue;
}
@@ -318,6 +319,14 @@ function defaultPrefilter( elem, props, opts ) {
length = handled.length;
if ( length ) {
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
}
// store state if its toggle - enables .stop().toggle() to "reverse"
if ( toggle ) {
dataShow.hidden = !hidden;
}
if ( hidden ) {
jQuery( elem ).show();
} else {