back to Overview

promise.stop()

Stops an ongoing operation, if supported.
Complete distribution only, not available in stand-alone modules.

Syntax

promise.stop()

Parameters

(return value)
In some cases, the stop() can return a value. This is currently only done by animate() and wait(), which will return the actual duration. asyncEach()'s promise will also return any value it got from the promise that it stopped.
var div = $('#myMovingDiv').set({$left: '0px', $top: '0px'});
var prom = div.animate({$left: '200px', $top: '0px'}, 600, 0)
.then(function() {
return _.promise(div.animate({$left: '200px', $top: '200px'}, 800, 0),
div.animate({$backgroundColor: '#f00'}, 200));
}).then(function() {
return div.animate({$left: '100px', $top: '100px'}, 400);
});$('#stopButton').on('click', prom.stop);

Description

Stops an ongoing operation, if supported. Currently the only promises supporting this are those returned by request(), animate(), wait() and asyncEach(). stop() invocation will be propagated over promises returned by then() and promises assimilated by promise(). You only need to invoke stop with the last promise, and all dependent promises will automatically stop as well.

stop() can be invoked as a function without context ('this'). Every promise has its own instance.

Example

Animation chain that can be stopped.

Comments

comments powered by Disqus

back to Overview

Functions