Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/unit/effects/effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
height: 50px;
}

.ticket7106 {
width: 50px;
opacity: 1;
}
.ticket7106.animate {
width: 100px;
}

</style>
</head>
<body>
Expand All @@ -94,6 +102,8 @@ <h2>Slide with relative width</h2>
</div>
<div class="testScale">
</div>
<div class="ticket7106">
</div>

</div>
</body>
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/effects/effects_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ test( "createWrapper and removeWrapper retain focused elements (#7595)", functio
equal( document.activeElement, input[ 0 ], "Active element is still input after createWrapper" );
$.effects.removeWrapper( test );
equal( document.activeElement, input[ 0 ], "Active element is still input after removeWrapper" );
})
});

asyncTest( "animateClass: css and class changes during animation are not lost (#7106)", function() {
$( "div.ticket7106" ).addClass( "animate", 300, function() {
equal( $(this).css( "opacity" ), "0.5", "css change during animateClass was lost" );
ok( $(this).hasClass( "testClass" ), "class change during animateClass was lost" );
start();
}).addClass( "testClass" ).css( { opacity: "0.5" } );
});

})(jQuery);
32 changes: 16 additions & 16 deletions ui/jquery.effects.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,27 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
return this.queue( function() {
var animated = $( this ),
baseClass = animated.attr( "class" ) || "",
finalClass,
applyClassChange,
allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;

// map the animated objects to store the original styles.
allAnimations = allAnimations.map(function() {
var el = $( this );
return {
el: el,
originalStyleAttr: el.attr( "style" ) || " ",
start: getElementStyles.call( this )
};
});

// apply class change
$.each( classAnimationActions, function(i, action) {
if ( value[ action ] ) {
animated[ action + "Class" ]( value[ action ] );
}
});
finalClass = animated.attr( "class" );
applyClassChange = function() {
$.each( classAnimationActions, function(i, action) {
if ( value[ action ] ) {
animated[ action + "Class" ]( value[ action ] );
}
});
};
applyClassChange();

// map all animated objects again - calculate new styles and diff
allAnimations = allAnimations.map(function() {
Expand Down Expand Up @@ -275,16 +276,15 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
$.when.apply( $, allAnimations.get() ).done(function() {

// set the final class
animated.attr( "class", finalClass );
applyClassChange();

// for each animated element
// for each animated element,
// clear all css properties that were animated
$.each( arguments, function() {
if ( typeof this.el.attr( "style" ) === "object" ) {
this.el.attr( "style" ).cssText = "";
this.el.attr( "style" ).cssText = this.originalStyleAttr;
} else {
this.el.attr( "style", this.originalStyleAttr );
}
var el = this.el;
$.each( this.diff, function(key) {
el.css( key, '' );
});
});

// this is guarnteed to be there if you use jQuery.speed()
Expand Down