Commit 493e1887 authored by charlie0228's avatar charlie0228 Committed by GitHub

fix: fix incorrect image object fit ratio in IE (#19583)

parent 18cf34f7
...@@ -204,7 +204,8 @@ ...@@ -204,7 +204,8 @@
if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) return {}; if (!imageWidth || !imageHeight || !containerWidth || !containerHeight) return {};
const vertical = imageWidth / imageHeight < 1; const imageAspectRatio = imageWidth / imageHeight;
const containerAspectRatio = containerWidth / containerHeight;
if (fit === ObjectFit.SCALE_DOWN) { if (fit === ObjectFit.SCALE_DOWN) {
const isSmaller = imageWidth < containerWidth && imageHeight < containerHeight; const isSmaller = imageWidth < containerWidth && imageHeight < containerHeight;
...@@ -215,9 +216,9 @@ ...@@ -215,9 +216,9 @@
case ObjectFit.NONE: case ObjectFit.NONE:
return { width: 'auto', height: 'auto' }; return { width: 'auto', height: 'auto' };
case ObjectFit.CONTAIN: case ObjectFit.CONTAIN:
return vertical ? { width: 'auto' } : { height: 'auto' }; return (imageAspectRatio < containerAspectRatio) ? { width: 'auto' } : { height: 'auto' };
case ObjectFit.COVER: case ObjectFit.COVER:
return vertical ? { height: 'auto' } : { width: 'auto' }; return (imageAspectRatio < containerAspectRatio) ? { height: 'auto' } : { width: 'auto' };
default: default:
return {}; return {};
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment