If hidden then shown Animation does not work
vikkio88 opened this issue · 4 comments
Hi there, nice project, I've learned so much from it, now I am trying out to show a spinner only if a certain condition happens and what I am seeing is that if is behind an IsVisible the animation does not work.
As an example I am putting here the xaml I use
IsVisible="{Binding !CanClickGenerate}"
Value="fa-spinner"
Animation="Pulse"/>
for some reason once that bool flips, I can see the icon but it is not animated, I also tried wrapping it in a Panel to avoid touching Icon itself but it didn't work
<Panel Margin="0,30,0,0"
IsVisible="{Binding !CanClickGenerate}">
<i:Icon FontSize="20"
Value="fa-spinner"
Animation="Pulse"/>
</Panel>
using it by itself works just fine
<i:Icon FontSize="20"
Value="fa-spinner"
Animation="Pulse"/>
So I don't really know what the problem is or whether this is a bug
I will look into it.
Maybe you could try an animation on another object than an icon to verify there is no bug in Avalonia itself?
will try it out, if you want I can share an example project
Nice. An example project would help me. Thanks.
I was trying to compose an example and it works fine, I think the problem is in my app, as I am running an async task and I thought the dispatcher would run it in another thread instead it locks the UI thread and prevents the animation to run.
I am toggling a bool when I click a button to show the icon and animate it, and somethings happens like this
GenerateTeams = ReactiveCommand.CreateFromTask(() =>
{
CanClickGenerate = false;
Dispatcher.UIThread.InvokeAsync(() =>
{
// a task that might take 1 second
CanClickGenerate = true;
}, DispatcherPriority.Background);
return Task.CompletedTask;
}, canGenerate);
I thought the dispatcher would run it somewhere else, maybe I misread the docs of avalonia, but it looks like it is not your issue man, thanks anyway