Skip to content

Commit

Permalink
fix: fix incorrect image object fit ratio in IE (ElemeFE#19583)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie0228 authored and BANKA2017 committed Mar 16, 2021
1 parent 03d68e3 commit bd1e172
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/image/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@
if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) return {};
const vertical = imageWidth / imageHeight < 1;
const imageAspectRatio = imageWidth / imageHeight;
const containerAspectRatio = containerWidth / containerHeight;
if (fit === ObjectFit.SCALE_DOWN) {
const isSmaller = imageWidth < containerWidth && imageHeight < containerHeight;
Expand All @@ -214,9 +215,9 @@
case ObjectFit.NONE:
return { width: 'auto', height: 'auto' };
case ObjectFit.CONTAIN:
return vertical ? { width: 'auto' } : { height: 'auto' };
return (imageAspectRatio < containerAspectRatio) ? { width: 'auto' } : { height: 'auto' };
case ObjectFit.COVER:
return vertical ? { height: 'auto' } : { width: 'auto' };
return (imageAspectRatio < containerAspectRatio) ? { height: 'auto' } : { width: 'auto' };
default:
return {};
}
Expand Down

0 comments on commit bd1e172

Please sign in to comment.