Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Flickering when opening popup, animated: false not working #84

Open
RandomMauiDev opened this issue Sep 24, 2023 · 4 comments

Comments

@RandomMauiDev
Copy link

RandomMauiDev commented Sep 24, 2023

As the title says there is flickering happening when opening popup with animation on Android, specifically Samsung Galaxy S22 Ultra in my case.
Using MopupService.Instance.PushAsync(popup, animate: false); does not disable the animation.
I found a workaround for this by setting IsAnimationEnabled="False" on the popup page.
But still having a nice animation would be better.

Here is what I am using on the page:

BackgroundClicked="OnBackgroundClicked"
BackgroundColor="#A0000000"
BackgroundInputTransparent="False"
CloseWhenBackgroundIsClicked="False"
@vchelaru
Copy link

I have also noticed this problem. Any update on the issue?

@tranb3r
Copy link

tranb3r commented Jan 25, 2024

I also noticed this issue.
I've managed to workaround the flickering bug by using this simplified custom animation code:

internal class ScaleAndFadeAnimation : BaseAnimation
{
    public double Scale { get; set; } = 0.8;

    public ScaleAndFadeAnimation()
    {
        EasingIn = Easing.SinOut;
        EasingOut = Easing.SinIn;
    }

    public override void Preparing(View content, PopupPage page)
    {
        HidePage(page);
    }

    public override void Disposing(View content, PopupPage page)
    {
        ShowPage(page);
    }

    public override Task Appearing(View content, PopupPage page)
    {
        return Task.WhenAll(
            page.FadeTo(1.0, DurationIn, EasingIn),
            ScaleAsync(content, EasingIn, Scale, 1.0, DurationIn)
        );
    }

    public override Task Disappearing(View content, PopupPage page)
    {
        return Task.WhenAll(
            page.FadeTo(0.0, DurationOut, EasingOut),
            ScaleAsync(content, EasingOut, 1.0, Scale, DurationOut)
        );
    }

    private static Task ScaleAsync(VisualElement content, Easing easing, double start, double end, uint length)
    {
        var task = new TaskCompletionSource();
        content.Animate("popupScale", 
            d => content.Scale = d,
            start, 
            end,
            easing: easing,
            length: length,
            finished: (_, _) => task.SetResult());
        return task.Task;
    }
}

@vchelaru
Copy link

@tranb3r can you explain how to use the ScaleAndFadeAnimation with Mopups? I'm looking at IPopupNavigation and I don't see a way to pass a BaseAnimation.

@tranb3r
Copy link

tranb3r commented Mar 18, 2024

@tranb3r can you explain how to use the ScaleAndFadeAnimation with Mopups? I'm looking at IPopupNavigation and I don't see a way to pass a BaseAnimation.

Look at the sample app here:

<Mopups:PopupPage.Animation>

You can use any custom animation class instead of the one provided by the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants