Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jsuarezruiz/xamanimation

Xamarin Forms Animation Library
https://github.com/jsuarezruiz/xamanimation

animation animation-library animations transitions xamarin xaml

Last synced: 2 days ago
JSON representation

Xamarin Forms Animation Library

Awesome Lists containing this project

README

        

# Xamanimation - Animation Library for Xamarin.Forms

**Xamanimation** is a library designed for Xamarin.Forms that aims to facilitate the use of **animations** to developers. Very simple use from **C# and XAML** code.

![Xamanimation](Media/xamanimation.gif)

We can define animations in XAML to a visual element when loading through a Behavior, use a trigger in XAML to execute the animation or from C# code.

Available animations:

- Color
- FadeTo
- Flip
- Heart
- Jump
- Rotate
- Scale
- Shake
- Translate
- Turnstile

## Installation

To install Xamanimation, run the following command in the Package Manager Console.

PM> Install-Package Xamanimation

## Animations directly from XAML

One of the main advantages of the library is the possibility of using animations from **XAML**. We must use the following namespace:

xmlns:xamanimation="clr-namespace:Xamanimation;assembly=Xamanimation"

Let's animate a BoxView:

we can define animations directly in XAML (as Application or Page Resources):

Using the namespace of xamanimation, we have access to the whole set of animations of the library. In all of them there are a number of common **parameters** such as:

- **Target**: Indicate the visual element to which we will apply the animation.
- **Duration**: Duration of the animation in milliseconds.

Depending on the animation type used, we will have more parameters to customize the specific animation. For example, in the case of Fade Animation we will have an Opacity property to set how we modify the opacity.

To launch the animation we have two options:

- **Trigger**: Called BeginAnimation that allows us to launch an animation when a condition occurs.
- **Behavior**: We have a Behavior called BeginAnimation that we can associate to a visual element so that indicating the desired animation, we can launch the same when the element load occurs.

Using the Clicked event of a button we can launch the previous animation using the trigger provided:







We also have the concept of **Storyboard** as a set of animations that we can execute over time:




## Using C#

In the same way that we can use the animations of the library from XAML, we can do it from **C#** code. We have an extension method called **Animate** that expects an instance of any of the available animations.

If we want to animate a BoxView called AnimationBox:

Access the element, use the Animate method with the desired animation:

AnimationBox.Animate(new HeartAnimation());

## Take control of the animation

You can control the duration of the animation using the **Duration** property. In addition to the type of **Easing** to use. Now, new properties have also been added such as:

**Delay** Add a delay before play the animation.

**Repeat Forever** Now you can create infinite animations if you need it.

## Triggers!

Triggers allow you to start animations declaratively in XAML based on events or property changes.

```
















```

You can animate any property of type Int, Double, Color, Thickness or CornerRadius. Available options:
* AnimateInt
* AnimateColor
* AnimateCornerRadius
* AnimateDouble
* AnimateThickness

## Progress Animations

Sometimes you need to animate something based on a value that changes over time, for example as a a the result of a user interaction.

A common scenario is using a scroll. A parallax effect, etc.

```




```

Available options:
* AnimateProgressInt
* AnimateProgressColor
* AnimateProgressCornerRadius
* AnimateProgressDouble
* AnimateProgressThickness

## Transitions

Provides the animated transition behavior on controls when they first appear. You can use this on individual objects or on containers of objects. In the latter case, child elements will animate into view in sequence rather than all at the same time.

```



```

## Feedback

Please use [GitHub issues](https://github.com/jsuarezruiz/xamanimation/issues) for questions or comments.

## Copyright and license

Code released under the [MIT license](https://opensource.org/licenses/MIT).