Skip to content

Commit ea17664

Browse files
authored
Disable Implicit animations when running under Uno (#326)
* Disable Implicit animations when running under Uno * Suppress CS0162 for disabled code
1 parent 0cb8b97 commit ea17664

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

components/Animations/src/Implicit.cs

+30
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ public static void SetAnimations(UIElement element, ImplicitAnimationSet value)
129129
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for the current event.</param>
130130
private static void OnShowAnimationsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
131131
{
132+
// See https://github.com/CommunityToolkit/Windows/issues/319
133+
#if HAS_UNO
134+
#pragma warning disable CS0162
135+
return;
136+
#endif
137+
132138
static void OnAnimationsChanged(object sender, EventArgs e)
133139
{
134140
var collection = (ImplicitAnimationSet)sender;
@@ -160,6 +166,10 @@ static void OnAnimationsChanged(object sender, EventArgs e)
160166
ElementCompositionPreview.SetImplicitShowAnimation(element, null);
161167
}
162168
}
169+
170+
#if HAS_UNO
171+
#pragma warning restore CS0162
172+
#endif
163173
}
164174

165175
/// <summary>
@@ -169,6 +179,12 @@ static void OnAnimationsChanged(object sender, EventArgs e)
169179
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for the current event.</param>
170180
private static void OnHideAnimationsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
171181
{
182+
// See https://github.com/CommunityToolkit/Windows/issues/319
183+
#if HAS_UNO
184+
#pragma warning disable CS0162
185+
return;
186+
#endif
187+
172188
static void OnAnimationsChanged(object sender, EventArgs e)
173189
{
174190
var collection = (ImplicitAnimationSet)sender;
@@ -200,6 +216,10 @@ static void OnAnimationsChanged(object sender, EventArgs e)
200216
ElementCompositionPreview.SetImplicitHideAnimation(element, null);
201217
}
202218
}
219+
220+
#if HAS_UNO
221+
#pragma warning restore CS0162
222+
#endif
203223
}
204224

205225
/// <summary>
@@ -209,6 +229,12 @@ static void OnAnimationsChanged(object sender, EventArgs e)
209229
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance for the current event.</param>
210230
private static void OnAnimationsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
211231
{
232+
// See https://github.com/CommunityToolkit/Windows/issues/319
233+
#if HAS_UNO
234+
#pragma warning disable CS0162
235+
return;
236+
#endif
237+
212238
static void OnAnimationsChanged(object sender, EventArgs e)
213239
{
214240
var collection = (ImplicitAnimationSet)sender;
@@ -240,5 +266,9 @@ static void OnAnimationsChanged(object sender, EventArgs e)
240266
ElementCompositionPreview.GetElementVisual(element).ImplicitAnimations = null;
241267
}
242268
}
269+
270+
#if HAS_UNO
271+
#pragma warning restore CS0162
272+
#endif
243273
}
244274
}

0 commit comments

Comments
 (0)