Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions source/FFImageLoading.Maui/CachedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,35 +489,35 @@ protected override void OnBindingContextChanged()
base.OnBindingContextChanged();
}

protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
{
var desiredSize = base.OnMeasure(double.PositiveInfinity, double.PositiveInfinity);
var desiredWidth = double.IsNaN(desiredSize.Request.Width) ? 0 : desiredSize.Request.Width;
var desiredHeight = double.IsNaN(desiredSize.Request.Height) ? 0 : desiredSize.Request.Height;
var desiredSize = base.MeasureOverride(double.PositiveInfinity, double.PositiveInfinity);
var desiredWidth = double.IsNaN(desiredSize.Width) ? 0 : desiredSize.Width;
var desiredHeight = double.IsNaN(desiredSize.Height) ? 0 : desiredSize.Height;

if (double.IsNaN(widthConstraint))
widthConstraint = 0;
if (double.IsNaN(heightConstraint))
heightConstraint = 0;

if (Math.Abs(desiredWidth) < double.Epsilon || Math.Abs(desiredHeight) < double.Epsilon)
return new SizeRequest(new Size(0, 0));
return new Size(0, 0);

if (double.IsPositiveInfinity(widthConstraint) && double.IsPositiveInfinity(heightConstraint))
{
return new SizeRequest(new Size(desiredWidth, desiredHeight));
return new Size(desiredWidth, desiredHeight);
}

if (double.IsPositiveInfinity(widthConstraint))
{
var factor = heightConstraint / desiredHeight;
return new SizeRequest(new Size(desiredWidth * factor, desiredHeight * factor));
return new Size(desiredWidth * factor, desiredHeight * factor);
}

if (double.IsPositiveInfinity(heightConstraint))
{
var factor = widthConstraint / desiredWidth;
return new SizeRequest(new Size(desiredWidth * factor, desiredHeight * factor));
return new Size(desiredWidth * factor, desiredHeight * factor);
}

var fitsWidthRatio = widthConstraint / desiredWidth;
Expand All @@ -529,17 +529,17 @@ protected override SizeRequest OnMeasure(double widthConstraint, double heightCo
fitsHeightRatio = 0;

if (Math.Abs(fitsWidthRatio) < double.Epsilon && Math.Abs(fitsHeightRatio) < double.Epsilon)
return new SizeRequest(new Size(0, 0));
return new Size(0, 0);

if (Math.Abs(fitsWidthRatio) < double.Epsilon)
return new SizeRequest(new Size(desiredWidth * fitsHeightRatio, desiredHeight * fitsHeightRatio));
return new Size(desiredWidth * fitsHeightRatio, desiredHeight * fitsHeightRatio);

if (Math.Abs(fitsHeightRatio) < double.Epsilon)
return new SizeRequest(new Size(desiredWidth * fitsWidthRatio, desiredHeight * fitsWidthRatio));
return new Size(desiredWidth * fitsWidthRatio, desiredHeight * fitsWidthRatio);

var ratioFactor = Math.Min(fitsWidthRatio, fitsHeightRatio);

return new SizeRequest(new Size(desiredWidth * ratioFactor, desiredHeight * ratioFactor));
return new Size(desiredWidth * ratioFactor, desiredHeight * ratioFactor);
}

public void SetIsLoading(bool isLoading)
Expand Down