vignesh kumar
vignesh kumar

Reputation: 2330

Using TranslateTo over Xamarin.Forms.Core.Animation for animation?

Currently I am working to make our application very responsive to the user, While working on that I came across the below code for showing indefinite progress bar to user

Task.Run(async () => {
    while (!_progressCts.IsCancellationRequested)
    {
        await (box as BoxView).TranslateTo(this.Width, 0, 1200);
        await (box as BoxView).TranslateTo(-this.Width, 0, 0);
    }
}, _progressCts.Token); 

This animation looks simple But From the documents I came to know that there is a separate class known as 'Xamarin.Forms.Core.Animation' for handling animations. My question is which one is better in terms of making UI responsive to the user.

The above code is to show an indefinite progress bar on top of a ListView But it is not at all disturbing the scrolling experience of the ListView.

Upvotes: 3

Views: 1137

Answers (1)

GKMoreira
GKMoreira

Reputation: 422

TranslateTo is a specific implementation that uses the Xamarin.Forms.Core.Animation resources. Both are responsive to the user, they don't freeze the app flow. Actually, the second one is doing the job in a separated thread, and the SO handles quick and smoothly the interface changes.

Look my answer here, it shows an alternative implementation to change the button background color using the same approach.

Upvotes: 2

Related Questions