| OLD | NEW |
| (Empty) |
| 1 Animation API | |
| 2 ============= | |
| 3 | |
| 4 ```dart | |
| 5 typedef void TimerCallback(); | |
| 6 | |
| 7 external void _addTask({ TimerCallback callback, Duration budget, int bits, int
priority, Queue queue }); | |
| 8 // see (runloop.md)[runloop.md] for the semantics of tasks and queues | |
| 9 // _addTask() does the zone magic on callback | |
| 10 | |
| 11 external final Queue get _idleQueue; | |
| 12 external final Queue get _paintQueue; | |
| 13 external final Queue get _nextPaintQueue; | |
| 14 | |
| 15 class AnimationTimer extends Timer { | |
| 16 factory whenIdle(TimerCallback callback, { Duration budget: 1.0 }) { | |
| 17 if (budget.inMilliseconds > 1.0) | |
| 18 budget = new Duration(milliseconds: 1.0); | |
| 19 _addTask(callback: callback, budget: budget, bits: IdleTask, priority: IdleP
riority, queue: _idleQueue); | |
| 20 } | |
| 21 | |
| 22 factory beforePaint(TimerCallback callback, { int priority: 0 }) { | |
| 23 _addTask(callback: callback, budget: new Duration(milliseconds: 1.0), bits:
PaintTask, priority: priority, queue: _paintQueue); | |
| 24 } | |
| 25 | |
| 26 factory nextFrame(TimerCallback callback, { int priority: 0 }) { | |
| 27 _addTask(callback: callback, budget: new Duration(milliseconds: 1.0), bits:
PaintTask, priority: priority, queue: _nextPaintQueue); | |
| 28 } | |
| 29 } | |
| 30 ``` | |
| 31 | |
| 32 | |
| 33 Easing Functions | |
| 34 ---------------- | |
| 35 | |
| 36 ```dart | |
| 37 // part of the framework, not dart:sky | |
| 38 | |
| 39 typedef void AnimationCallback(); | |
| 40 | |
| 41 abstract class EasingFunction { | |
| 42 EasingFunction({double duration: 0.0, AnimationCallback completionCallback: nu
ll }); | |
| 43 double getFactor(Float time); | |
| 44 // calls completionCallback if time >= duration | |
| 45 // then returns a number ostensibly in the range 0.0 to 1.0 | |
| 46 // (but it could in practice go outside this range, e.g. for | |
| 47 // animation styles that overreach then come back) | |
| 48 } | |
| 49 ``` | |
| 50 | |
| 51 If you want to have two animations simultaneously, e.g. two | |
| 52 transforms, then you can add to the RenderNode's overrideStyles a | |
| 53 StyleValue that combines other StyleValues, e.g. a | |
| 54 "TransformStyleValueCombinerStyleValue", and then add to it the | |
| 55 regular animated StyleValues, e.g. multiple | |
| 56 "AnimatedTransformStyleValue" objects. A framework API could make | |
| 57 setting all that up easy, given the right underlying StyleValue | |
| 58 classes. | |
| OLD | NEW |