简化Flutter交错动画。用动画配置的形式,经过时间线去驱动Flutter的交错动画。你能够git
Flutter Animation Set
现有的动画组件Flutter Animation Set
去建立新的动画组件Flutter Animation Set
动画组件Curves
动画效果dependencies:
flutter_animation_set: ^0.0.3
复制代码
一、importgithub
import 'package:flutter_animation_set/widget/transition_animations.dart';
import 'package:flutter_animation_set/widget/behavior_animations.dart';
复制代码
二、useapi
child: YYRotatingPlane(),
复制代码
三、road mapapp
transition_animations 过渡动画less
![]() YYRotatingPlane ✅ |
![]() YYDoubleBounce ✅ |
![]() YYWave ✅ |
![]() YYWanderingCubes ✅ |
![]() YYFadingFour ✅ |
![]() YYFadingCube ✅ |
![]() YYPulse ✅ |
![]() YYThreeBounce ✅ |
![]() YYThreeLine ✅ |
![]() YYCubeGrid ✅ |
![]() YYRotatingCircle ✅ |
![]() YYPumpingHeart ✅ |
![]() YYRipple ✅ |
![]() YYRotateLine ✅ |
![]() YYCubeFadeIn ✅ |
![]() YYBlinkGrid ✅ |
behavior_animations 行为动画ide
![]() YYFadeButton ✅ |
![]() YYSingleLike ✅ |
![]() YYLove ✅ |
![]() YYSpringMenu ✅ |
![]() YYFoldMenu ✅ |
四、thankssvg
一、importpost
import 'package:flutter_animation_set/animation_set.dart';
import 'package:flutter_animation_set/animator.dart';
复制代码
二、use widget动画
经过使用AnimatorSet组装动画ui
AnimatorSet(
child: widget.child,
animatorSet: [],
)
复制代码
三、use api
about animation widget
Widget | Mean | Description |
---|---|---|
W | width | 控制宽度的变化,若是是按比例拉升,建议用SX替代 |
H | height | 控制高度的变化,若是是按比例拉升,建议用SY替代 |
P | padding | 控制边距的变化 |
O | opacity | 控制透明度的变化 |
SX | scaleX | 以中点进行X轴的缩放 |
SY | scaleY | 以中点进行Y轴的缩放 |
RX | rotateX | 以中点进行X轴的旋转 |
RY | rotateY | 以中点进行Y轴的旋转 |
RZ | rotateZ | 以中点进行Z轴的旋转 |
TX | transitionX | 进行X轴的平移 |
TY | transitionY | 进行Y轴的平移 |
C | color | 控制背景颜色变化 |
B | border | 控制背景边框变化 |
about support widget
Widget | Mean | Description |
---|---|---|
Delay | delay timeLine | 延长时间线,进入等待阶段 |
Serial | combine animation | 经过组合动画,达到一块儿播放的效果 |
一、create timeLine
二、build animatorSet
经过上面的图示组装咱们的动画组件,动画组件带有如下属性
animatorSet: [
Delay(duration: before),
SY(from: 0.8, to: 1.6, duration: 200, delay: 0, curve: Curves.linear),
SY(from: 1.6, to: 0.8, duration: 200, delay: 0, curve: Curves.linear),
Delay(duration: after),
],
复制代码
动画执行的对象是Container
长方形
Widget makeWave(int before, int after) {
return AnimatorSet(
child: Container(
color: Colors.white,
width: 5,
height: 15,
),
animatorSet: [
Delay(duration: before),
SY(from: 0.8, to: 1.6, duration: 200, delay: 0, curve: Curves.linear),
SY(from: 1.6, to: 0.8, duration: 200, delay: 0, curve: Curves.linear),
Delay(duration: after),
],
);
}
复制代码
三、convert to code
class YYWave extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 40,
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
makeWave(0, 500),
makeWave(100, 400),
makeWave(200, 300),
makeWave(300, 200),
makeWave(400, 100),
makeWave(500, 0),
],
),
);
}
}
复制代码
四、done
一、组合动画
缩放效果须要同时缩放X、Y轴,用到Serial组件
animatorSet: [
Serial(
duration: 2000,
serialList: [
SX(from: 0.0, to: 1.0, curve: Curves.easeInOut),
SY(from: 0.0, to: 1.0, curve: Curves.easeInOut),
O(from: 0.5, to: 0.0, delay: 1000, curve: Curves.easeInOut),
],
),
],
复制代码
done
二、延时动画
对真正作动画的时候处理delay属性
class YYThreeLine extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 40,
height: 40,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
makeLine(0),
makeLine(50),
makeLine(100),
],
),
);
}
}
Widget makeLine(int delay) {
return AnimatorSet(
child: Container(
color: Colors.white,
width: 10,
height: 5,
),
animatorSet: [
TY(from: 0.0, to: 5.0, duration: 400, delay: delay, curve: Curves.fastOutSlowIn,),
TY(from: 5.0, to: 0.0, duration: 400, curve: Curves.fastOutSlowIn,),
],
);
}
复制代码
done
三、倒退动画
动画能够播放完成后,经过animationType属性设置AnimationType.reverse
,让动画接着倒退播放
class YYFoldMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
width: 40,
height: 40,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
makeFoldMenu(0, 40),
makeFoldMenu(100, 26.0),
makeFoldMenu(200, 12.0),
],
),
);
}
}
Widget makeFoldMenu(int delay, double toY) {
return AnimatorSet(
animationType: AnimationType.reverse,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
),
width: 30,
height: 10,
),
animatorSet: [
Serial(
duration: 2000,
delay: delay,
serialList: [
TY(from: 0.0, to: toY, curve: Curves.elasticInOut),
SX(from: 1.0, to: 0.1, curve: Curves.elasticInOut),
SY(from: 1.0, to: 0.1, curve: Curves.elasticInOut),
],
),
],
);
}
复制代码
done
Apache License 2.0