.wait(triggerFunction ,callback)

Description: Wait to continue invocation depending on the result value of the callback function.

triggerFunction – function(count…)
a method that is called to determine the trigger to wait for. The return value is evaluated according to its type. See other versions of .wait() for possible return values.
All current iteration counts/events (from inner-most to outer-most loop) are passed as arguments.
callback – function(count…), optional
a method that is called once before continuing.
All current iteration counts/events (from inner-most to outer-most loop) are passed as arguments.

Examples with waiting for trigger from function result

Example #19: pause animation cycle on mouseover

There is a animation cycle rotating three images. Once you move the mouse cursor over it, it pauses until the mouse is moved away.

A little helper function checks whether the mouse is over the image. If that's the case a deferred jQuery object waiting for the mouseleave event is returned.
function noHover() {
    return this.is(':hover') ? this.wait('mouseleave') : this
}

The running loop can be written in a single jQuery line.

$('#images > img').hide().repeat().each($).fadeIn($)
    .wait(1000).wait(noHover).fadeOut($);