I'm using JQuery UI to addClass(), and later to removeClass().
If removeClass() is called before addClass() completes, it queues up and executes later. This is not ideal, I'd rather have the removeClass() execute immediately from the current CSS values.
If I invoke stop() just before add/removeClass(), animation seems permanently 'frozen' at the moment of the stop() call, though the add/removeClass() callback still fires.
Just the JS here:
var obj = $("#obj");
obj.addClass("obj");
$("#add").click(function(){
//obj.addClass("adder", 2000, "easeInOutCubic", onAdded);
obj.stop().addClass("adder", 2000, "easeInOutCubic", onAdded);
});
$("#remove").click(function(){
//obj.removeClass("adder", 2000, "easeInOutCubic", onRemoved);
obj.stop().removeClass("adder", 2000, "easeInOutCubic", onRemoved);
});
function onAdded () { console.log("added"); }
function onRemoved () { console.log("removed"); }
All the rest here: http://jsfiddle.net/mmstM/42/
This seems like it would be a common issue but haven't found any good info on SO or elsewhere...note this is for JQuery UI, not core.