Skip to content

Commit

Permalink
fix: Contain story does not work proper way with more square images #69
Browse files Browse the repository at this point in the history
… (#70)
  • Loading branch information
CyberDex authored Jan 15, 2024
1 parent 8280732 commit d718ab2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/controllers/SizeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,19 +596,18 @@ export class SizeController

if (minWidth || minHeight)
{
let finalMinScaleToFit = finalScaleToFit;

if (layoutWidth * finalScaleToFit < minWidthVal)
if (minWidth && minHeight)
{
finalMinScaleToFit = minFitScaleX;
finalScaleToFit = Math.max(minFitScaleX, minFitScaleY);
}

if (layoutHeight * finalScaleToFit < minHeightVal)
else if (minWidth)
{
finalMinScaleToFit = minFitScaleY;
finalScaleToFit = finalScaleX;
}
else if (minHeight)
{
finalScaleToFit = minFitScaleY;
}

finalScaleToFit = Math.max(finalMinScaleToFit, finalMinScaleToFit);
}

this.layout.container.scale.set(finalScaleToFit);
Expand Down
4 changes: 3 additions & 1 deletion src/stories/fit/Contain.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class LayoutStory
styles: {
position: 'center',
maxWidth: '100%',
minHeight: '100%'
maxHeight: '100%',
minHeight: '100%',
minWidth: '100%',
}
},
styles: {
Expand Down

0 comments on commit d718ab2

Please sign in to comment.