Commit 86087cbb authored by Hixie's avatar Hixie

RotationTransition

A transition that rotates its contents.
parent babba2f0
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:vector_math/vector_math_64.dart' show Matrix4;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:vector_math/vector_math_64.dart' show Matrix4;
import 'basic.dart'; import 'basic.dart';
import 'framework.dart'; import 'framework.dart';
...@@ -90,6 +92,29 @@ class SlideTransition extends TransitionWithChild { ...@@ -90,6 +92,29 @@ class SlideTransition extends TransitionWithChild {
} }
} }
class RotationTransition extends TransitionWithChild {
RotationTransition({
Key key,
this.turns,
PerformanceView performance,
Widget child
}) : super(key: key,
performance: performance,
child: child);
final AnimatedValue<double> turns;
Widget buildWithChild(BuildContext context, Widget child) {
performance.updateVariable(turns);
Matrix4 transform = new Matrix4.rotationZ(turns.value * math.PI * 2.0);
return new Transform(
transform: transform,
alignment: const FractionalOffset(0.5, 0.5),
child: child
);
}
}
class FadeTransition extends TransitionWithChild { class FadeTransition extends TransitionWithChild {
FadeTransition({ FadeTransition({
Key key, Key key,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment