Skip to content

Commit

Permalink
Core: Fixed switchClass queueing issues using lazy evaluation of elem…
Browse files Browse the repository at this point in the history
…ent's style. Fixed #6244 - switchClass queues incorrectly.
  • Loading branch information
Adovenmuehle authored and scottgonzalez committed Nov 19, 2010
1 parent a2e0eb9 commit abfa0e1
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions ui/jquery.effects.core.js
Expand Up @@ -232,33 +232,41 @@ $.effects.animateClass = function(value, duration, easing, callback) {
}

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

var that = $(this),
originalStyleAttr = that.attr('style') || ' ',
originalStyle = filterStyles(getElementStyles.call(this)),
newStyle,
className = that.attr('className');

$.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]); }
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); }
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);
}
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);
});
});
};
Expand Down

0 comments on commit abfa0e1

Please sign in to comment.