Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: sky/specs/animation.md

Issue 909403002: Specs: First draft of timer API for scheduling things for this frame or next frame or when idle. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Animation API 1 Animation API
2 ============= 2 =============
3 3
4 (This is very incomplete, because it's all expected to be in the 4 ```dart
5 framework, not the platform.) 5 typedef void TimerCallback();
6 6
7 ```javascript 7 class AnimationTimer extends Timer {
8 external factory whenIdle(TimerCallback callback, { double budget: 1.0 });
9 // calls callback next time the system is idle
10 // - if budget is in the range 0.0 < budget <= 1.0, then callback is
11 // guaranteed to have that many milliseconds before being killed
12 // - if budget <= 0.0, then the callback could be killed [at any time](script. md).
13 // - if budget > 1.0, then it is treated as 1.0.
8 14
9 dictionary EasingFunctionSettings { 15 external factory beforePaint(TimerCallback callback, { int priority: 0 });
10 Float duration; // required 16 // runs this timeout before this frame's layout/paint phases begin
11 Callback? completionCallback = null; 17 external factory nextFrame(TimerCallback callback, { int priority: 0 });
12 } 18 // runs this timeout right away
13 19
14 abstract class EasingFunction { 20 // for beforePaint and nextFrame, the callbacks are first sorted by
15 abstract constructor (EasingFunctionSettings settings); 21 // priority, and then run in decreasing order of priority,
16 abstract Float getFactor(Float time); 22 // tie-breaking by registration time, earliest first.
17 // calls completionCallback if time >= duration 23
18 // then returns a number ostensibly in the range 0.0 to 1.0 24 // once there is no more time for callbacks this frame, the Timers
19 // (but it could in practice go outside this range, e.g. for 25 // are all canceled, so isActive will become false
20 // animation styles that overreach then come back) 26
21 } 27 }
22 ``` 28 ```
23 29
24 30
31 Easing Functions
32 ----------------
33
34 ```dart
35 // part of the framework, not sky:core
36
37 typedef void AnimationCallback();
38
39 abstract class EasingFunction {
40 EasingFunction({double duration: 0.0, AnimationCallback completionCallback: nu ll });
41 double getFactor(Float time);
42 // calls completionCallback if time >= duration
43 // then returns a number ostensibly in the range 0.0 to 1.0
44 // (but it could in practice go outside this range, e.g. for
45 // animation styles that overreach then come back)
46 }
47 ```
48
25 If you want to have two animations simultaneously, e.g. two 49 If you want to have two animations simultaneously, e.g. two
26 transforms, then you can add to the RenderNode's overrideStyles a 50 transforms, then you can add to the RenderNode's overrideStyles a
27 StyleValue that combines other StyleValues, e.g. a 51 StyleValue that combines other StyleValues, e.g. a
28 "TransformStyleValueCombinerStyleValue", and then add to it the 52 "TransformStyleValueCombinerStyleValue", and then add to it the
29 regular animated StyleValues, e.g. multiple 53 regular animated StyleValues, e.g. multiple
30 "AnimatedTransformStyleValue" objects. A framework API could make 54 "AnimatedTransformStyleValue" objects. A framework API could make
31 setting all that up easy, given the right underlying StyleValue 55 setting all that up easy, given the right underlying StyleValue
32 classes. 56 classes.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698