Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
46
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 8 Advanced UI Concepts

Cancelling Animations

Providing the ability to cancel an animation can be an extremely valuable feature for a user. Quite often in applications, and predominantly games, an animation will show when an action completes. Animations like this if blocking can become tiresome for users especially if the same animation repeats frequently. Therefore, a common pattern to follow is when the user taps on the control being animated, it cancels the animation.

If you wish to cancel an animation, you can call the CancelAnimations extension method on the VisualElement that you are animating.

AddWidgetFrame.CancelAnimations();

Easings

Animations in general will move mechanically as a computer changes a value over time. Easings allow you to move away from a linear update of those values in order to provide a much more organic and natural motion.

.NET MAUI offers a whole host of prebuilt easings, plus there is even the ability to build your own if you really wish to do so. Let’s take a look at the options that .NET MAUI provides out of the box:

Easing function

Description

 

 

BounceIn

Bounces the animation at the beginning

BounceOut

Bounces the animation at the end

CubicIn

Slowly accelerates the animation

CubicInOut

Accelerates the animation at the beginning and decelerates the

 

animation at the end

CubicOut

Quickly decelerates the animation

Linear

Uses a constant velocity and is the default easing function

 

 

246