Created
September 18, 2015 07:04
-
-
Save programmation/01f1fdfc8485bb9b7ad1 to your computer and use it in GitHub Desktop.
Xamarin Forms View extension (wobble)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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