Skip to content
Permalink
Browse files
Class Animation: Use .attr( "class" ) instead of .attr( "className" )…
… and adjust the queueing logic for jQuery 1.6 compatibility. Fixes #7275 - $.effects.animateClass broken in jQuery 1.6.
  • Loading branch information
scottgonzalez committed Apr 27, 2011
1 parent df7e300 commit 5439940
Showing 1 changed file with 21 additions and 22 deletions.
@@ -231,41 +231,40 @@ $.effects.animateClass = function(value, duration, easing, callback) {
easing = null;
}

return this.queue('fx', function() {
return this.queue(function() {
var that = $(this),
originalStyleAttr = that.attr('style') || ' ',
originalStyle = filterStyles(getElementStyles.call(this)),
newStyle,
className = that.attr('className');
className = that.attr('class');

$.each(classAnimationActions, function(i, action) {
if (value[action]) {
that[action + 'Class'](value[action]);
}
});
newStyle = filterStyles(getElementStyles.call(this));
that.attr('className', className);

that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
$.each(classAnimationActions, function(i, action) {
if (value[action]) { that[action + 'Class'](value[action]); }
});
// work around bug in IE by clearing the cssText before setting it
if (typeof that.attr('style') == 'object') {
that.attr('style').cssText = '';
that.attr('style').cssText = originalStyleAttr;
} else {
that.attr('style', originalStyleAttr);
that.attr('class', className);

that.animate(styleDifference(originalStyle, newStyle), {
queue: false,
duration: duration,
easding: easing,
complete: function() {
$.each(classAnimationActions, function(i, action) {
if (value[action]) { that[action + 'Class'](value[action]); }
});
// work around bug in IE by clearing the cssText before setting it
if (typeof that.attr('style') == 'object') {
that.attr('style').cssText = '';
that.attr('style').cssText = originalStyleAttr;
} else {
that.attr('style', originalStyleAttr);
}
if (callback) { callback.apply(this, arguments); }
$.dequeue( this );
}
if (callback) { callback.apply(this, arguments); }
});

// $.animate adds a function to the end of the queue
// but we want it at the front
var queue = $.queue(this),
anim = queue.splice(queue.length - 1, 1)[0];
queue.splice(1, 0, anim);
$.dequeue(this);
});
};

0 comments on commit 5439940

Please sign in to comment.