RotationTransition
A transition that rotates its contents.
This commit is contained in:
parent
babba2f0ec
commit
86087cbb08
@ -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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user