Skip to content

Commit

Permalink
add Tween#stop(). Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 29, 2013
1 parent f1d2181 commit e970f7e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/ball.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
}

animate();
</script>
</script>
4 changes: 3 additions & 1 deletion examples/circle.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<canvas width=500 height=400></canvas>

<button onclick='tween.stop()'>Stop</button>

<script>
var Tween = require('tween');
var raf = require('component-raf');
Expand Down Expand Up @@ -40,4 +42,4 @@
}

animate();
</script>
</script>
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ Tween.prototype.ease = function(fn){
return this;
};

/**
* Stop the tween and immediately emit "stop" and "end".
*
* @return {Tween}
* @api public
*/

Tween.prototype.stop = function(){
this.stopped = true;
this._done = true;
this.emit('stop');
this.emit('end');
return this;
};

/**
* Perform a step.
*
Expand Down

0 comments on commit e970f7e

Please sign in to comment.