Permalink
Browse files

document stop() method

bump minor version
  • Loading branch information...
1 parent 3e0cfa2 commit a2c64ecf4e7251c13152a8ce15d015e7f418b3ec @ded committed Oct 17, 2011
Showing with 51 additions and 12 deletions.
  1. +8 −1 README.md
  2. +1 −1 package.json
  3. +1 −0 support/bowser
  4. +1 −0 support/sink
  5. +40 −10 tests/tests.html
View
9 README.md
@@ -9,7 +9,7 @@ Morpheus lets you "tween anything" in parallel on multiple elements; from colors
It looks like this:
``` js
-morpheus(elements, {
+var anim = morpheus(elements, {
// CSS
left: -50
, top: 100
@@ -28,6 +28,12 @@ morpheus(elements, {
console.log('done')
}
})
+
+// stop an animation
+anim.stop()
+
+// jump to the end of an animation and run 'complete' callback
+anim.stop(true)
```
General Tweening
@@ -66,6 +72,7 @@ API
* - complete: a callback method for when all elements have finished
* - bezier: array of arrays containing x|y coordinates that define the bezier points. defaults to none
* - this may also be a function that receives element to be animated. it must return a value
+ * @return animation instance
*/
```
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "morpheus"
, "description": "A Brilliant Animator"
- , "version": "0.6.0"
+ , "version": "0.6.1"
, "homepage": "https://github.com/ded/morpheus"
, "author": "Dustin Diaz <polvero@gmail.com> (http://dustindiaz.com)"
, "keywords": ["ender", "animation", "motion", "css", "colors", "morph", "tween", "curve", "bezier", "transform", "skew", "rotate"]
1 support/bowser
@@ -0,0 +1 @@
+Subproject commit 1ea37f33dabd521c33748bddb9a988e080862614
1 support/sink
@@ -0,0 +1 @@
+Subproject commit 5b82553c81a3561b6525e72468caeeb3557687d4
View
50 tests/tests.html
@@ -32,7 +32,7 @@
el.style.left = 0
el.style.top = '10px'
})
- test('should accept non-pixel value', 1, function() {
+ test('should accept raw number value sans-unit', 1, function () {
morpheus(el, {
left: 5,
duration: 10,
@@ -160,16 +160,46 @@
}
sink('Transform', function(test, ok, before, after) {
- transformTest(test,ok,'should accept absolute rotate','rotate(30deg)','rotate(40deg)','v.rotate == 40')
- transformTest(test,ok,'should accept relative rotate','rotate(10deg)','rotate(-=20deg)','v.rotate == -10 || v.rotate == 350')
- transformTest(test,ok,'should accept absolute scale','scale(1)','scale(3)','v.scale == 3')
- transformTest(test,ok,'should accept relative scale','scale(1)','scale(+=3)','v.scale == 4')
- transformTest(test,ok,'should accept absolute skew','skew(10deg,10deg)','skew(30deg,90deg)',['v.skewx == 30','v.skewy == 90'])
- transformTest(test,ok,'should accept relative skew','skew(10deg,10deg)','skew(+=30deg,-=6deg)',['v.skewx == 40','v.skewy == 4'])
- transformTest(test,ok,'should accept absolute translate','translate(-10px,0px)','translate(30px,99px)',['v.translatex == 30','v.translatey == 99'])
- transformTest(test,ok,'should accept relative translate','translate(100px,100px)','translate(+=30px,-=106px)',['v.translatex == 130','v.translatey == -6'])
+ transformTest(test, ok, 'should accept absolute rotate','rotate(30deg)','rotate(40deg)','v.rotate == 40')
+ transformTest(test, ok, 'should accept relative rotate','rotate(10deg)','rotate(-=20deg)','v.rotate == -10 || v.rotate == 350')
+ transformTest(test, ok, 'should accept absolute scale','scale(1)','scale(3)','v.scale == 3')
+ transformTest(test, ok, 'should accept relative scale','scale(1)','scale(+=3)','v.scale == 4')
+ transformTest(test, ok, 'should accept absolute skew','skew(10deg,10deg)','skew(30deg,90deg)',['v.skewx == 30','v.skewy == 90'])
+ transformTest(test, ok, 'should accept relative skew','skew(10deg,10deg)','skew(+=30deg,-=6deg)',['v.skewx == 40','v.skewy == 4'])
+ transformTest(test, ok, 'should accept absolute translate','translate(-10px,0px)','translate(30px,99px)',['v.translatex == 30','v.translatey == 99'])
+ transformTest(test, ok, 'should accept relative translate','translate(100px,100px)','translate(+=30px,-=106px)',['v.translatex == 130','v.translatey == -6'])
})
- start();
+
+ sink('Out', function (test, ok) {
+ var el = document.getElementById('test')
+ test('stop() method should stop an animation and run callback', 1, function () {
+ var inst = morpheus(el, {
+ duration: 10000
+ , left: 100
+ , complete: function () {
+ ok(false, 'callback should not be called')
+ }
+ })
+ inst.stop()
+ setTimeout(function() {
+ ok(parseFloat(el.style.left) < 100, 'did not animate to full extent')
+ }, 10)
+
+ })
+ test('stop(jump) should stop animation, jump to end, and *not* fire callback', 2, function () {
+ var inst = morpheus(el, {
+ duration: 10000
+ , left: 100
+ , complete: function () {
+ ok(true, 'callback should have been called')
+ ok(parseFloat(el.style.left) == 100, 'jumped to end of animation')
+ }
+ })
+ inst.stop(true)
+ })
+ })
+
+ start()
</script>
</body>

0 comments on commit a2c64ec

Please sign in to comment.