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; } ///