From 6fdcd2e14d42e61830aaf4e31dbfd396a23bcd50 Mon Sep 17 00:00:00 2001 From: microspaze Date: Thu, 16 May 2024 11:10:35 +0800 Subject: [PATCH] Fix MoveAnimation animation is not triggered when opening with PopupNavigation.Instance.PushAsync #15 --- RGPopup.Maui/Animations/Base/BaseAnimation.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/RGPopup.Maui/Animations/Base/BaseAnimation.cs b/RGPopup.Maui/Animations/Base/BaseAnimation.cs index aace560..5f638f2 100644 --- a/RGPopup.Maui/Animations/Base/BaseAnimation.cs +++ b/RGPopup.Maui/Animations/Base/BaseAnimation.cs @@ -32,12 +32,16 @@ public abstract class BaseAnimation : IPopupAnimation protected virtual int GetTopOffset(View content, Page page) { - return (int)(content.Height + page.Height) / 2; + var pageHeight = page.Height; + var contentHeight = content.Height; + return pageHeight > 0 && contentHeight > 0 ? (int)(contentHeight + pageHeight) / 2 : (int)page.Window.Height; } protected virtual int GetLeftOffset(View content, Page page) { - return (int)(content.Width + page.Width) / 2; + var pageWidth = page.Width; + var contentWidth = content.Width; + return pageWidth > 0 && contentWidth > 0 ? (int)(contentWidth + pageWidth) / 2 : (int)page.Window.Width; } ///