Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:vector_math/vector_math.dart'; | |
| 8 | |
| 7 import '../animation/animated_value.dart'; | 9 import '../animation/animated_value.dart'; |
| 10 import '../animation/animation_performance.dart'; | |
| 11 import '../animation/curves.dart'; | |
| 8 import 'basic.dart'; | 12 import 'basic.dart'; |
| 9 | 13 |
| 10 class _AnimationEntry { | 14 class _AnimationEntry { |
| 11 _AnimationEntry(this.value); | 15 _AnimationEntry(this.value); |
| 12 final AnimatedValue value; | 16 final AnimatedValue value; |
| 13 StreamSubscription<double> subscription; | 17 StreamSubscription<double> subscription; |
| 14 } | 18 } |
| 15 | 19 |
| 16 abstract class AnimatedComponent extends Component { | 20 abstract class AnimatedComponent extends Component { |
| 17 | 21 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 43 void didUnmount() { | 47 void didUnmount() { |
| 44 for (_AnimationEntry entry in _animatedFields) { | 48 for (_AnimationEntry entry in _animatedFields) { |
| 45 assert(entry.subscription != null); | 49 assert(entry.subscription != null); |
| 46 entry.subscription.cancel(); | 50 entry.subscription.cancel(); |
| 47 entry.subscription = null; | 51 entry.subscription = null; |
| 48 } | 52 } |
| 49 super.didUnmount(); | 53 super.didUnmount(); |
| 50 } | 54 } |
| 51 | 55 |
| 52 } | 56 } |
| 57 | |
| 58 // Types of things that can be animated in a component. Use build() to | |
| 59 // construct the final Widget based on the animation state. | |
| 60 // TODO(mpcomplete): the idea here is to eventually have an AnimatedCollection | |
| 61 // which assembles a container based on a list of animated things. e.g. if you | |
| 62 // want to animate position, opacity, and shadow, you add those animators to an | |
| 63 // AnimatedCollection and just call collection.build() to construct your | |
| 64 // widget. | |
|
Hixie
2015/06/30 23:11:56
I don't really understand how this will look.
Matt Perry
2015/07/01 18:17:43
See my reply to abarth's comment in this file. Let
| |
| 65 | |
| 66 class AnimatedPosition extends AnimatedType<Point> { | |
| 67 AnimatedPosition(Point begin, Point end, {Curve curve: linear}) | |
| 68 : super(begin, end, curve: curve); | |
| 69 | |
| 70 Widget build({Widget child}) { | |
| 71 Matrix4 transform = new Matrix4.identity(); | |
| 72 transform.translate(value.x, value.y); | |
| 73 return new Transform(transform: transform, child: child); | |
| 74 } | |
| 75 } | |
| OLD | NEW |