Commit 86087cbb authored by Hixie's avatar Hixie

RotationTransition

A transition that rotates its contents.
parent babba2f0
......@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/animation.dart';
import 'package:vector_math/vector_math_64.dart' show Matrix4;
import 'package:flutter/rendering.dart';
import 'package:vector_math/vector_math_64.dart' show Matrix4;
import 'basic.dart';
import 'framework.dart';
......@@ -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 {
FadeTransition({
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