feat: animation.

This commit is contained in:
Zhang Dian
2024-09-05 18:41:55 +08:00
parent 22fc7f5424
commit f830da7799
3 changed files with 19 additions and 21 deletions

View File

@@ -99,21 +99,18 @@
<Animation
Easing="QuadraticEaseIn"
FillMode="Forward"
Duration="0:0:0.45">
Duration="0:0:0.3">
<KeyFrame Cue="0%">
<Setter Property="Opacity" Value="0" />
<Setter Property="TranslateTransform.Y" Value="20" />
<Setter Property="ScaleTransform.ScaleX" Value="0.85" />
<Setter Property="ScaleTransform.ScaleY" Value="0.85" />
</KeyFrame>
<KeyFrame Cue="30%">
<Setter Property="TranslateTransform.Y" Value="-20" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="Opacity" Value="1" />
</KeyFrame>
<KeyFrame KeySpline="0.22,0.57,0.02,1.2" Cue="0%">
<Setter Property="TranslateTransform.Y" Value="-100" />
</KeyFrame>
<KeyFrame KeySpline="0.22,0.57,0.02,1.2" Cue="100%">
<Setter Property="TranslateTransform.Y" Value="0" />
<Setter Property="ScaleTransform.ScaleX" Value="1" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
</Animation>
</ControlTheme.Animations>
@@ -124,18 +121,18 @@
<Animation
Easing="QuadraticEaseOut"
FillMode="Forward"
Duration="0:0:0.75">
Duration="0:0:0.3">
<KeyFrame Cue="0%">
<Setter Property="TranslateTransform.X" Value="0" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
</KeyFrame>
<KeyFrame Cue="70%">
<Setter Property="TranslateTransform.X" Value="800" />
<Setter Property="ScaleTransform.ScaleY" Value="1" />
<Setter Property="Opacity" Value="1" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="ScaleTransform.ScaleY" Value="0" />
<Setter Property="TranslateTransform.X" Value="800" />
<Setter Property="Opacity" Value="0" />
</KeyFrame>
<KeyFrame KeySpline="0.22,0.57,0.02,1.2" Cue="0%">
<Setter Property="TranslateTransform.Y" Value="0" />
</KeyFrame>
<KeyFrame KeySpline="0.22,0.57,0.02,1.2" Cue="100%">
<Setter Property="TranslateTransform.Y" Value="-100" />
</KeyFrame>
</Animation>
</Style.Animations>
@@ -146,7 +143,7 @@
<Animation
Easing="QuadraticEaseOut"
FillMode="Forward"
Duration="0:0:1.25">
Duration="0:0:0.3">
<KeyFrame Cue="100%">
<Setter Property="IsClosed" Value="True" />
</KeyFrame>

View File

@@ -35,7 +35,8 @@ public class Toast : IToast, INotifyPropertyChanged
{
Content = content;
Type = type;
Expiration = expiration ?? TimeSpan.FromSeconds(5);
Expiration = expiration ?? TimeSpan.FromSeconds(3);
ShowClose = showClose;
OnClick = onClick;
OnClose = onClose;
}

View File

@@ -146,7 +146,7 @@ public class WindowToastManager : TemplatedControl, IManagedToastManager
return;
}
await Task.Delay(expiration ?? TimeSpan.FromSeconds(5));
await Task.Delay(expiration ?? TimeSpan.FromSeconds(3));
toastControl.Close();
}