您的位置:首页 > 其它

【开源】LLMAnimator 60多种动画让你的应用动起来

2016-03-21 09:50 197 查看
github: https://github.com/brookshi/LLMAnimator ,欢迎star/fork

之前做android的时候需要给应用加些动画效果,在github上找到这个库:

https://github.com/daimajia/AndroidViewAnimations,用起来挺方便,效果也不错。

现在做uwp,想要加些动画就想到这个库,于是开发了LLMAnimator,算是上面android库的uwp移植版本。

先看效果:

public enum AnimationType
{
Bounce,
Flash,
Pulse,
RubberBand,
Shake,
StandUp,
Swing,
Tada,
Wave,
Wobble,

BounceIn,
BounceInDown,
BounceInUp,
BounceInLeft,
BounceInRight,

FadeIn,
FadeInDown,
FadeInUp,
FadeInLeft,
FadeInRight,

FadeOut,
FadeOutDown,
FadeOutUp,
FadeOutLeft,
FadeOutRight,

FlipInX,
FlipInY,

FlipOutX,
FlipOutY,

RotateIn,
RotateInDownLeft,
RotateInDownRight,
RotateInUpLeft,
RotateInUpRight,

RotateOut,
RotateOutDownLeft,
RotateOutDownRight,
RotateOutUpLeft,
RotateOutUpRight,

SlideInDown,
SlideInUp,
SlideInLeft,
SlideInRight,

SlideOutDown,
SlideOutUp,
SlideOutLeft,
SlideOutRight,

ZoomIn,
ZoomInDown,
ZoomInUp,
ZoomInLeft,
ZoomInRight,

ZoomOut,
ZoomOutDown,
ZoomOutUp,
ZoomOutLeft,
ZoomOutRight,

Hinge,
RollIn,
RollOut,
DropOut,
Landing,
TakingOff,
}


View Code
如果有其他动画需求,也可以留言。

实现也很简单,以Bounce为例:

public class BounceAnimation : AnimationBase
{
public BounceAnimation()
{
Duration = TimeSpan.FromMilliseconds(800);
}

public override IAnimation PlayOn(UIElement target, Action continueWith)
{
var transform = Utils.PrepareTransform(target, typeof(CompositeTransform));

var storyboard = PrepareStoryboard(continueWith);

AddAnimationToStoryboard(storyboard, transform, CreateAnimation(), "TranslateY");

storyboard.Begin();

return this;
}

Timeline CreateAnimation()
{
DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();
var firstTimeSpan = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 8);

frames.KeyFrames.Add(new EasingDoubleKeyFrame()
{
EasingFunction = new SineEase()
{
EasingMode = EasingMode.EaseIn
},
KeyTime = KeyTime.FromTimeSpan(firstTimeSpan),
Value = -8,
});
frames.KeyFrames.Add(new EasingDoubleKeyFrame()
{
EasingFunction = new BounceEase()
{
Bounces = 2,
Bounciness = 1.3,
EasingMode = EasingMode.EaseOut
},
KeyTime = KeyTime.FromTimeSpan(Duration),
Value = 0,
});

return frames;
}
}


和大家平常创建动画的过程一样,这个库只是把常用的动画都集合在一起,这样用起来很方便,希望大家喜欢。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: