summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2016-03-29 12:19:05 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2016-03-29 12:19:05 +0200
commit8460b3b9fabe8129f38889282c9a3ad0dce50fc9 (patch)
tree614449780bbaae93885098eec31e663178ee3878 /README.md
parent1787f953b0708a405175968a8adc244dd5861d77 (diff)
downloadsvg.js-8460b3b9fabe8129f38889282c9a3ad0dce50fc9.tar.gz
svg.js-8460b3b9fabe8129f38889282c9a3ad0dce50fc9.zip
readme update, clean up
Diffstat (limited to 'README.md')
-rw-r--r--README.md105
1 files changed, 77 insertions, 28 deletions
diff --git a/README.md b/README.md
index 92ade2c..3317748 100644
--- a/README.md
+++ b/README.md
@@ -2110,8 +2110,49 @@ rect.finish() // rect at 250,250 with size 300,400
__`returns`: `itself`__
-### during()
-If you want to perform your own actions during the animations you can use the `during()` method:
+### loop()
+By default the `loop()` method creates and eternal loop:
+
+```javascript
+rect.animate(3000).move(100, 100).loop()
+```
+
+But the loop can also be a predefined number of times:
+
+```javascript
+rect.animate(3000).move(100, 100).loop(3)
+```
+
+Loops go from beginning to end and start over again (`0->1.0->1.0->1.`).
+
+There is also a reverse flag that should be passed as the second argument:
+
+```javascript
+rect.animate(3000).move(100, 100).loop(3, true)
+```
+
+Loops will then be completely reversed before starting over (`0->1->0->1->0->1.`).
+
+__`returns`: `SVG.FX`__
+
+### reverse()
+Toggles the direction of the animation or sets it to a specific direction:
+
+```javascript
+// will run from 100,100 to rects initial position
+rect.animate(3000).move(100, 100).reverse()
+
+// sets direction to backwards
+rect.animate(3000).move(100, 100).reverse(true)
+
+// sets direction to forwards (same as not calling reverse ever)
+rect.animate(3000).move(100, 100).reverse(false)
+```
+
+__`returns`: `SVG.FX`__
+
+### during/duringAll()
+If you want to perform your own actions during one/all animation you can use the `during()/duringAll()` method:
```javascript
var position
@@ -2121,6 +2162,11 @@ var position
rect.animate(3000).move(100, 100).during(function(pos, morph, eased, situation) {
position = from + (to - from) * pos
})
+
+// or
+rect.animate(3000).move(100, 100).duringAll(function(pos, morph, eased, situation) {
+ position = from + (to - from) * pos
+})
```
Note that `pos` is `0` in the beginning of the animation and `1` at the end of the animation.
@@ -2141,48 +2187,51 @@ rect.animate(3000).move(100, 100).during(function(pos, morph, eased, situation)
})
```
The `eased` parameter contains the position after the easing function was applied.
-The last parameter holds the current situation related to that `during` call.
-You can call `during()` multiple times to add more functions which should be executed.
+The last parameter holds the current situation related to the current `during` call.
+You can call `during()/duringAll()` multiple times to add more functions which should be executed.
__`returns`: `SVG.FX`__
-### loop()
-By default the `loop()` method creates and eternal loop:
+### after/afterAll()
+Furthermore, you can add callback methods using `after()/afterAll()`:
```javascript
-rect.animate(3000).move(100, 100).loop()
-```
-
-But the loop can also be a predefined number of times:
+rect.animate(3000).move(100, 100).after(function(situation) {
+ this.animate().attr({ fill: '#f06' })
+})
-```javascript
-rect.animate(3000).move(100, 100).loop(3)
+// or
+rect.animate(3000).move(100, 100).afterAll(function() {
+ this.animate().attr({ fill: '#f06' })
+})
```
-Loops go from beginning to end and start over again (`0->1.0->1.0->1.`).
+The function gets the situation which was finished as first parameter. This doesn't apply to afterAll where no parameter is passed
+Note that the `after()/afterAll()` method will never be called if the animation is looping eternally.
+You can call `after()/afterAll()` multiple times to add more functions which should be executed.
-There is also a reverse flag that should be passed as the second argument:
+__`returns`: `SVG.FX`__
+
+### once()
+Finally, you can perform an action at a specific position only once.
+Just pass the position and the function which should be executed to the `once` method.
+You can also decide whether the position which is passed should be handled as position in time (not eased) or position in space (easing applied):
```javascript
-rect.animate(3000).move(100, 100).loop(3, true)
+// the 0.5 is handled as uneased value (you can omit the false)
+rect.animate(3000).move(100, 100).once(0.5, function(pos, eased) {
+ // do something
+}, false)
```
-Loops will then be completely reversed before starting over (`0->1->0->1->0->1.`).
-
-__`returns`: `SVG.FX`__
-
-### after()
-Finally, you can add callback methods using `after()`:
-
```javascript
-rect.animate(3000).move(100, 100).after(function(situation) {
- this.animate().attr({ fill: '#f06' })
-})
+// the 0.5 is handled as eased value
+rect.animate(3000).move(100, 100).once(0.5, function(pos, eased) {
+ // do something
+}, true)
```
-The function gets the situation which was finished as first parameter.
-Note that the `after()` method will never be called if the animation is looping eternally.
-You can call `after()` multiple times to add more functions which should be executed.
+The callback function gets the current position uneased and eased
__`returns`: `SVG.FX`__