Skip to content

Instantly share code, notes, and snippets.

@programmation
Created September 18, 2015 07:04
Show Gist options
  • Save programmation/01f1fdfc8485bb9b7ad1 to your computer and use it in GitHub Desktop.
Save programmation/01f1fdfc8485bb9b7ad1 to your computer and use it in GitHub Desktop.
Xamarin Forms View extension (wobble)
public static class ViewExtensions
{
public static void Wobble (this View view, int wobbles = 4, Action completion = null)
{
Task.Run (() => {
Device.BeginInvokeOnMainThread (async () => {
uint duration = 50;
var count = 4;
await view.RelRotateTo (5.0, duration, Easing.Linear);
for (var shake = 1; shake < count - 1; shake++) {
await view.RelRotateTo (-10.0, duration, Easing.Linear);
await view.RelRotateTo (10.0, duration, Easing.Linear);
}
await view.RelRotateTo (-5.0, duration, Easing.Linear);
if (completion != null) {
completion ();
}
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment