Skip to content

Commit 0973c9e

Browse files
committed
added a delay on the animation to remove the breathing animation
1 parent faa9918 commit 0973c9e

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

App/Controls/ExpandContent.xaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,29 @@
2222
<Storyboard x:Name="ExpandSb">
2323
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
2424
Storyboard.TargetProperty="MaxHeight"
25-
To="10000" Duration="0:0:0.12"
25+
To="10000" Duration="0:0:0.16" BeginTime="0:0:0.16"
2626
EnableDependentAnimation="True"/>
2727
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
28-
Storyboard.TargetProperty="Opacity"
29-
To="1" Duration="0:0:0.12"/>
28+
Storyboard.TargetProperty="Opacity" BeginTime="0:0:0.16"
29+
To="1" Duration="0:0:0.16"/>
3030
<DoubleAnimation Storyboard.TargetName="Slide"
31-
Storyboard.TargetProperty="Y"
32-
To="0" Duration="0:0:0.12"/>
31+
Storyboard.TargetProperty="Y" BeginTime="0:0:0.16"
32+
To="0" Duration="0:0:0.16"/>
3333
</Storyboard>
3434
</VisualState>
3535
<VisualState x:Name="CollapsedState">
3636
<Storyboard x:Name="CollapseSb"
3737
Completed="{x:Bind CollapseStoryboard_Completed}">
3838
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
3939
Storyboard.TargetProperty="MaxHeight"
40-
To="0" Duration="0:0:0.12"
40+
To="0" Duration="0:0:0.16"
4141
EnableDependentAnimation="True"/>
4242
<DoubleAnimation Storyboard.TargetName="CollapsiblePanel"
4343
Storyboard.TargetProperty="Opacity"
44-
To="0" Duration="0:0:0.12"/>
44+
To="0" Duration="0:0:0.16"/>
4545
<DoubleAnimation Storyboard.TargetName="Slide"
4646
Storyboard.TargetProperty="Y"
47-
To="-16" Duration="0:0:0.12"/>
47+
To="-16" Duration="0:0:0.16"/>
4848
</Storyboard>
4949
</VisualState>
5050

App/Controls/ExpandContent.xaml.cs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public sealed partial class ExpandContent : UserControl
1717

1818
private bool? _pendingIsOpen;
1919

20-
private static readonly SemaphoreSlim _sem = new(1, 1);
21-
2220

2321
public ExpandContent()
2422
{
@@ -45,30 +43,21 @@ partial void OnIsOpenChanged(bool oldValue, bool newValue)
4543

4644
private async Task AnimateAsync(bool open)
4745
{
48-
await _sem.WaitAsync();
49-
50-
try
46+
if (open)
5147
{
52-
if (open)
53-
{
54-
if (_currentlyOpen is not null && _currentlyOpen != this)
55-
await _currentlyOpen.StartCollapseAsync();
48+
if (_currentlyOpen is not null && _currentlyOpen != this)
49+
await _currentlyOpen.StartCollapseAsync();
5650

57-
_currentlyOpen = this;
58-
CollapsiblePanel.Visibility = Visibility.Visible;
51+
_currentlyOpen = this;
52+
CollapsiblePanel.Visibility = Visibility.Visible;
5953

60-
VisualStateManager.GoToState(this, "ExpandedState", true);
61-
await ExpandAsync(); // wait for your own expand
62-
}
63-
else
64-
{
65-
if (_currentlyOpen == this) _currentlyOpen = null;
66-
await StartCollapseAsync();
67-
}
54+
VisualStateManager.GoToState(this, "ExpandedState", true);
55+
await ExpandAsync();
6856
}
69-
finally
57+
else
7058
{
71-
_sem.Release();
59+
if (_currentlyOpen == this) _currentlyOpen = null;
60+
await StartCollapseAsync();
7261
}
7362
}
7463

0 commit comments

Comments
 (0)