Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add Tween#stop(). Closes #2

  • Loading branch information...
commit e970f7ea4d06d232b02ad37af7deffd94d1e2566 1 parent f1d2181
@tj tj authored
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
2  examples/ball.html
@@ -61,4 +61,4 @@
}
animate();
-</script>
+</script>
View
4 examples/circle.html
@@ -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
15 index.js
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.