I need to have multiple animations cycling, or randomly changing, every time animation occurs on single function.
Currently there's a fade, what I want is to cycle through for example fade, toggle, animate, etc
Here is my code i need it to be used in:
var items = $(".items").on("click", "div", function() {
var not = $.map($(".items div").not(this), function(el) {
return $(el).index(".items div")
});
var next = not[Math.floor(Math.random() * not.length)];
var index = $(this).index(".items div");
var elems = $(">div", items).toArray();
[elems[next], elems[index]] = [elems[index], elems[next]];
$(this).add(items.find("div").eq(next)).fadeTo(600, 0, function() {
items.html(elems).find("div").fadeTo(600, 1)
});
});
I cant find any information about this anywhere but I saw it being used in some scripts, thanks a lot for ideas
.promise()on the jQuery objects). Then just run them sequentially/randomly (using.then()to run sequentially).