aboutsummaryrefslogtreecommitdiffstats
path: root/useCases.md
diff options
context:
space:
mode:
authorSaivan <savian@me.com>2018-05-22 16:50:56 +1000
committerSaivan <savian@me.com>2018-05-22 16:50:56 +1000
commita41c1496ba72796676085a6ade7a0fecb4d5b4ab (patch)
tree283069f3190f922c44764746a0c2ed34bbdc1315 /useCases.md
parent69b4111399015e1ad5ba28951bb264bafea21861 (diff)
parent837cc126d35dfa1387d0073fdb7f45fa36543f4b (diff)
downloadsvg.js-a41c1496ba72796676085a6ade7a0fecb4d5b4ab.tar.gz
svg.js-a41c1496ba72796676085a6ade7a0fecb4d5b4ab.zip
Added a few more use cases and such
Diffstat (limited to 'useCases.md')
-rw-r--r--useCases.md124
1 files changed, 124 insertions, 0 deletions
diff --git a/useCases.md b/useCases.md
index eb21068..a623eec 100644
--- a/useCases.md
+++ b/useCases.md
@@ -42,3 +42,127 @@ This block of code would:
- Spend the first 1000ms moving the element
- At this time, it will snap the scale to 1.5 (halfway to 2)
- After this time, the scale and the move should go together
+
+
+# Rotating While Scaling
+
+The user may want to run multiple animations concurrently and have
+control over each animation that they define.
+
+```js
+
+let animationA = element.loop(300, ">").rotate(360).runner()
+let animationB = element
+ .loop(200, "><")
+ .scale(2)
+ .runner(tag)
+
+// After some time, they might want to end the first animation abruptly
+animationB.enable(false).end()
+
+// Maybe they want to pause a runner
+animationB.enable(false)
+
+// Maybe they want to remove an animation matching a tag
+animationB.tag('B')
+element.timeline().remove('B')
+
+// They can move around a runner as well
+element.timeline()
+ .schedule('B', 300) // Moves a runner to start at 300
+ // time(currentAbsolute - newAbsolute)
+ .shift('B', 300) // Shifts the runner start time by 300
+ // seek(shiftTime)
+
+```
+
+
+# A Sequenced Animation
+
+The user might want to be able to run a long sequenced animation that they have
+predesigned as they please.
+
+```js
+
+let timeline = element.loop(300, "><").scale(2)
+ .animate(300).rotate(30)
+ .animate(300, 200).fill(blue)
+
+// They might want to move forwards or backwards
+timeline.seek(-300)
+
+// They might want to set a specific time
+timeline.time(200)
+
+// Or a specific position
+timeline.position(0.3)
+
+// Maybe they want to clear the timeline
+timeline.reset()
+
+```
+
+
+# User wants to Loop Something
+
+If the user wants to loop something, they should be able to call the loop
+method at any time, and it will just change the behaviour of the current
+runner. If we are running declaratively, we will throw an error.
+
+## Correct Usages
+
+They can invoke this from the timeline
+
+```js
+element.loop(duration, times, swing)
+```
+
+If they want to work with absolute times, they should animate first
+
+```js
+element.animate(300, 200, true)
+ .loop(Infinity, true)
+```
+
+Or alternatively, they could equivalently do this:
+
+```js
+element.loop({
+ now: true,
+ times: Infinity,
+ delay: 200,
+ duration: 300,
+ swing: true,
+ wait: [200, 300]
+})
+```
+
+## Error Case
+
+
+
+# Declarative Animations
+
+The user might want to have something chase their mouse around. This would
+require a declarative animation.
+
+```js
+
+el.animate((curr, target, dt, ctx) => {
+
+ // Find the error and the value
+ let error = target - current
+ ctx.speed = (ctx.error - error) / dt
+ ctx.error = error
+ return newPos
+
+})
+
+SVG.on(document, 'mousemove', (ev) => {
+
+ el.timeline(controller)
+ .move(ev.pageX, ev.pageY)
+
+})
+
+```