Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to stop permanent animation on custom view?

$
0
0

I try to create a custom Xamarin View, that performs an animation in repeat mode infinite.
I can't find events or methods to subclass to stop the animation when the view is removed from the view hierarchy, which means when the view is no more visible on the screen (screen hidden, application on paused, etc.).
I'm trying to do it on the view directly, not on a custom renderer for each platform.

Here is a sample of code of a view growing 10x it's size in 1 second repeatedly, but how can we stop it?
In fact, it's also more to understand how the Xamarin Forms View are handling memory as they are not implementing the IDisposable pattern.

`
public MyView()
{
InitializeComponent();

        UploadingAnimation();
    }

    private async void UploadingAnimation()
    {
        new Animation(delegate(double f)
        {
            this.Scale = f;
        }, this.Scale, 10.0, Easing.Linear, null).Commit(this, "ScaleTo", 16, 1000, null, delegate(double f, bool a)
        {
            Debug.WriteLine("Animation done");
            this.Scale = 1.0;
        }, delegate() {
            return true;
        });
    }`

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>