Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
Changes to stop method. Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
antonjb committed Feb 27, 2014
1 parent ec19c25 commit 70cecac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var foo = new Sprite(..., frames);
### play([options])
Starts the animation.

- `options` (Object) - Override any of the options set previously. See Options.
- `options` (Object) - Override any of the options set previously. [See Options](#options).

```javascript
var foo = new Sprite(..., ..., {fps: 12, reverse: true});
Expand All @@ -71,7 +71,7 @@ Stops the animation, optionally on a specific frame.
- `options` (Object)
- `frame` (Number) - Frame number to stop on
- `animated` (Boolean) - If stopping should be animated
- `callback` (Function) - Called on completion of `stop`
- `onComplete` (Function) - Called on completion of `stop`

### frame([value])
Getter/Setter for frame.
Expand Down
8 changes: 4 additions & 4 deletions sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,26 @@
* @param {Object} options - Optional options
* {Number} frame - Frame to stop on
* {Boolean} animated - Whether to animate to the stopping frame
* {Function} callback - Callback once Sprite is stopped
* {Function} onComplete - Callback once Sprite is stopped
* @returns {Sprite}
*/
this.stop = function(options){
var that = this;

if (!isPlaying) {return this;}

options = mergeObjects({callback: fun, frame: currentFrame, animated: false}, options);
options = mergeObjects({onComplete: fun, frame: currentFrame, animated: false}, options);
options.frame = isNumeric(options.frame) ? options.frame : currentFrame;
clearRequestInterval(animationTick);
isPlaying = false;

if (!options.animated) {
this.frame(options.frame);
options.callback.call(this);
options.onComplete.call(this);
} else {
this.play({reverse: currentOptions.reverse, fps: currentOptions.fps, onFrame: function(currentFrame){
if (options.frame === currentFrame) {
that.stop({callback: options.callback});
that.stop({onComplete: options.onComplete});
}
}});
}
Expand Down
2 changes: 1 addition & 1 deletion sprite.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 70cecac

Please sign in to comment.