| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. | 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style | 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at | 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd | 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ | 7 */ |
| 8 library charted.selection.transition; | 8 library charted.selection.transition; |
| 9 | 9 |
| 10 import "dart:html" show Element,document; | 10 import "dart:html" show Element, document; |
| 11 import "package:charted/core/timer.dart"; | 11 import "package:charted/core/timer.dart"; |
| 12 import "package:charted/selection/selection.dart"; | 12 import "package:charted/selection/selection.dart"; |
| 13 import "package:charted/core/interpolators.dart"; | 13 import "package:charted/core/interpolators.dart"; |
| 14 | 14 |
| 15 part 'src/transition_impl.dart'; | 15 part 'src/transition_impl.dart'; |
| 16 | 16 |
| 17 typedef Interpolator AttrTweenCallback(datum, int ei, String attr); | 17 typedef Interpolator AttrTweenCallback(datum, int ei, String attr); |
| 18 typedef Interpolator StyleTweenCallback(datum, int ei, String style); | 18 typedef Interpolator StyleTweenCallback(datum, int ei, String style); |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Transitions are created using the transition operator on a selection. | 21 * Transitions are created using the transition operator on a selection. |
| 22 * Transitions start automatically upon creation after a delay which defaults | 22 * Transitions start automatically upon creation after a delay which defaults |
| 23 * to zero; however, note that a zero-delay transition actually starts after a | 23 * to zero; however, note that a zero-delay transition actually starts after a |
| 24 * minimal (~17ms) delay, pending the first timer callback. | 24 * minimal (~17ms) delay, pending the first timer callback. |
| 25 * Transitions have a default duration of 250ms. | 25 * Transitions have a default duration of 250ms. |
| 26 */ | 26 */ |
| 27 abstract class Transition { | 27 abstract class Transition { |
| 28 | |
| 29 /** A settable default easing type */ | 28 /** A settable default easing type */ |
| 30 static EasingFunction defaultEasingType = easeCubic(); | 29 static EasingFunction defaultEasingType = easeCubic(); |
| 31 | 30 |
| 32 /** A settable default easing mode */ | 31 /** A settable default easing mode */ |
| 33 static EasingModeFunction defaultEasingMode = reflectEasingFn; | 32 static EasingModeFunction defaultEasingMode = reflectEasingFn; |
| 34 | 33 |
| 35 /** A settable default transition duration */ | 34 /** A settable default transition duration */ |
| 36 static int defaultDurationMilliseconds = 250; | 35 static int defaultDurationMilliseconds = 250; |
| 37 | 36 |
| 38 /** Sets the ease function of the transition, default is cubic-in-out. */ | 37 /** Sets the ease function of the transition, default is cubic-in-out. */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 */ | 100 */ |
| 102 void style(String property, String val, [String priority]); | 101 void style(String property, String val, [String priority]); |
| 103 | 102 |
| 104 /** | 103 /** |
| 105 * Transitions the style with a CartedCallback which would be evaluated for | 104 * Transitions the style with a CartedCallback which would be evaluated for |
| 106 * each selected element (in order), being passed the current datum d and the | 105 * each selected element (in order), being passed the current datum d and the |
| 107 * current index i, and the current DOM element. | 106 * current index i, and the current DOM element. |
| 108 * The function's return value is then used to transition each element's | 107 * The function's return value is then used to transition each element's |
| 109 * style property. | 108 * style property. |
| 110 */ | 109 */ |
| 111 void styleWithCallback(String property, | 110 void styleWithCallback(String property, SelectionCallback<String> fn, |
| 112 SelectionCallback<String> fn, [String priority]); | 111 [String priority]); |
| 113 | 112 |
| 114 /** | 113 /** |
| 115 * Transitions the value of the CSS style property with the specified name | 114 * Transitions the value of the CSS style property with the specified name |
| 116 * according to the specified tween function. An optional priority may also | 115 * according to the specified tween function. An optional priority may also |
| 117 * be specified, either as null or the string "important" (without the | 116 * be specified, either as null or the string "important" (without the |
| 118 * exclamation point). The starting and ending value of the transition are | 117 * exclamation point). The starting and ending value of the transition are |
| 119 * determined by tween; the tween function is invoked when the transition | 118 * determined by tween; the tween function is invoked when the transition |
| 120 * starts on each element, being passed the current datum d, the current index | 119 * starts on each element, being passed the current datum d, the current index |
| 121 * i and the current attribute value a. The return value of tween must be an | 120 * i and the current attribute value a. The return value of tween must be an |
| 122 * interpolator: a function that maps a parametric value t in the domain [0,1] | 121 * interpolator: a function that maps a parametric value t in the domain [0,1] |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 /** | 162 /** |
| 164 * Removes all selected elements from the DOM at the end of the transition. | 163 * Removes all selected elements from the DOM at the end of the transition. |
| 165 * If any of the selected elements have another transition scheduled when | 164 * If any of the selected elements have another transition scheduled when |
| 166 * this transition ends, said elements will not be removed. | 165 * this transition ends, said elements will not be removed. |
| 167 */ | 166 */ |
| 168 void remove(); | 167 void remove(); |
| 169 | 168 |
| 170 /** Factory method to create an instance of the default implementation */ | 169 /** Factory method to create an instance of the default implementation */ |
| 171 factory Transition(Selection selection) => new _TransitionImpl(selection); | 170 factory Transition(Selection selection) => new _TransitionImpl(selection); |
| 172 } | 171 } |
| OLD | NEW |