mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Reworked animations
This commit is contained in:
parent
12b33c5376
commit
8708c7ffe6
9 changed files with 159 additions and 85 deletions
59
MapControl/Avalonia/OpacityHelper.Avalonia.cs
Normal file
59
MapControl/Avalonia/OpacityHelper.Avalonia.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Styling;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public static class OpacityHelper
|
||||
{
|
||||
public static Task FadeIn(Control element)
|
||||
{
|
||||
var animation = new Animation
|
||||
{
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
Children =
|
||||
{
|
||||
new KeyFrame
|
||||
{
|
||||
KeyTime = TimeSpan.Zero,
|
||||
Setters = { new Setter(Visual.OpacityProperty, 0d) }
|
||||
},
|
||||
new KeyFrame
|
||||
{
|
||||
KeyTime = MapBase.ImageFadeDuration,
|
||||
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return animation.RunAsync(element);
|
||||
}
|
||||
|
||||
public static async Task SwapOpacities(Control topElement, Control bottomElement)
|
||||
{
|
||||
var animation = new Animation
|
||||
{
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
Children =
|
||||
{
|
||||
new KeyFrame
|
||||
{
|
||||
KeyTime = MapBase.ImageFadeDuration,
|
||||
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
await animation.RunAsync(topElement);
|
||||
|
||||
bottomElement.Opacity = 0d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,35 +2,13 @@
|
|||
// Copyright © 2024 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using Avalonia.Animation;
|
||||
using Avalonia.Styling;
|
||||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class Tile
|
||||
{
|
||||
private void AnimateImageOpacity()
|
||||
{
|
||||
var animation = new Animation
|
||||
{
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
Children =
|
||||
{
|
||||
new KeyFrame
|
||||
{
|
||||
KeyTime = TimeSpan.Zero,
|
||||
Setters = { new Setter(Visual.OpacityProperty, 0d) }
|
||||
},
|
||||
new KeyFrame
|
||||
{
|
||||
KeyTime = MapBase.ImageFadeDuration,
|
||||
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_ = animation.RunAsync(Image);
|
||||
_ = OpacityHelper.FadeIn(Image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue