Last active
February 27, 2018 15:27
-
-
Save colinkiama/659bf5f135436512c90745b1835b0a15 to your computer and use it in GitHub Desktop.
Use Community Toolkit to animate a FontIcon continuously. Speed can be adjusted.
This file contains 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
private async Task animateSyncingIcon() | |
{ | |
nowSyncing = true; | |
var centerX = (float)syncIcon.ActualWidth / 2; | |
var centerY = (float)syncIcon.ActualHeight / 2; | |
const int maxRotation = 360; | |
double rotationsToPerform = 10; | |
double rotationsPerSecond = (double)(1 / rotationsToPerform); | |
var duration = (float)(rotationsPerSecond / maxRotation); | |
int rotation = 1; | |
while (nowSyncing) | |
{ | |
if (rotation == maxRotation) | |
{ | |
await syncIcon.Rotate(0, centerX, centerY, 0).StartAsync(); | |
rotation = 0; | |
} | |
await syncIcon.Rotate(rotation, centerX, centerY, duration).StartAsync(); | |
rotation += (int)rotationsToPerform; | |
} | |
Fioe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment