Permalink
Browse files

add Tween#stop(). Closes #2

  • Loading branch information...
1 parent f1d2181 commit e970f7ea4d06d232b02ad37af7deffd94d1e2566 @tj tj committed May 29, 2013
Showing with 19 additions and 2 deletions.
  1. +1 −1 examples/ball.html
  2. +3 −1 examples/circle.html
  3. +15 −0 index.js
View
@@ -61,4 +61,4 @@
}
animate();
-</script>
+</script>
View
@@ -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');
@@ -40,4 +42,4 @@
}
animate();
-</script>
+</script>
View
@@ -93,6 +93,21 @@ Tween.prototype.ease = function(fn){
};
/**
+ * 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.
*
* @return {Tween} self

0 comments on commit e970f7e

Please sign in to comment.