This is not tested, but should give you a good idea.
function waitOnTransition(elem, endIndex, callback){ var transitionIndex = 0; $(elem).on('webkitTransitionEnd', function(){ if(transitionIndex == endIndex){ callback(); }else{ transitionIndex++; } }); } waitOnTransition('#elemID', 3, function(){
You can also do this with curry
function makeTransitionEnd(endIndex){ var endIndex = endIndex; var out = function(elem, callback){ var transitionIndex = 0; $(elem).on('webkitTransitionEnd', function(){ if(transitionIndex == endIndex){ callback(); }else{ transitionIndex++; } }); }); return out; }
Fresheyeball
source share