Skip to content

Commit abfa0e1

Browse files
Adovenmuehlescottgonzalez
authored andcommitted
Core: Fixed switchClass queueing issues using lazy evaluation of element's style. Fixed #6244 - switchClass queues incorrectly.
1 parent a2e0eb9 commit abfa0e1

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

ui/jquery.effects.core.js

+32-24
Original file line numberDiff line numberDiff line change
@@ -232,33 +232,41 @@ $.effects.animateClass = function(value, duration, easing, callback) {
232232
}
233233

234234
return this.each(function() {
235+
$.queue(this, 'fx', function() {
236+
var that = $(this),
237+
originalStyleAttr = that.attr('style') || ' ',
238+
originalStyle = filterStyles(getElementStyles.call(this)),
239+
newStyle,
240+
className = that.attr('className');
235241

236-
var that = $(this),
237-
originalStyleAttr = that.attr('style') || ' ',
238-
originalStyle = filterStyles(getElementStyles.call(this)),
239-
newStyle,
240-
className = that.attr('className');
241-
242-
$.each(classAnimationActions, function(i, action) {
243-
if (value[action]) {
244-
that[action + 'Class'](value[action]);
245-
}
246-
});
247-
newStyle = filterStyles(getElementStyles.call(this));
248-
that.attr('className', className);
249-
250-
that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
251242
$.each(classAnimationActions, function(i, action) {
252-
if (value[action]) { that[action + 'Class'](value[action]); }
243+
if (value[action]) {
244+
that[action + 'Class'](value[action]);
245+
}
253246
});
254-
// work around bug in IE by clearing the cssText before setting it
255-
if (typeof that.attr('style') == 'object') {
256-
that.attr('style').cssText = '';
257-
that.attr('style').cssText = originalStyleAttr;
258-
} else {
259-
that.attr('style', originalStyleAttr);
260-
}
261-
if (callback) { callback.apply(this, arguments); }
247+
newStyle = filterStyles(getElementStyles.call(this));
248+
that.attr('className', className);
249+
250+
that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
251+
$.each(classAnimationActions, function(i, action) {
252+
if (value[action]) { that[action + 'Class'](value[action]); }
253+
});
254+
// work around bug in IE by clearing the cssText before setting it
255+
if (typeof that.attr('style') == 'object') {
256+
that.attr('style').cssText = '';
257+
that.attr('style').cssText = originalStyleAttr;
258+
} else {
259+
that.attr('style', originalStyleAttr);
260+
}
261+
if (callback) { callback.apply(this, arguments); }
262+
});
263+
264+
// $.animate adds a function to the end of the queue
265+
// but we want it at the front
266+
var queue = $.queue(this),
267+
anim = queue.splice(queue.length - 1, 1)[0];
268+
queue.splice(1, 0, anim);
269+
$.dequeue(this);
262270
});
263271
});
264272
};

0 commit comments

Comments
 (0)