[Canvas] Repeat image bug with image height fixed. (#121497) (#121895)

* Fixed typo and increased performance.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	src/plugins/expression_repeat_image/public/components/repeat_image_component.tsx
This commit is contained in:
Yaroslav Kuznietsov 2021-12-22 20:20:24 +02:00 committed by GitHub
parent 95115453a0
commit 63bac2e2a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,8 +46,10 @@ function setImageSize(img: HTMLImageElement, size: number) {
}
function createImageJSX(img: HTMLImageElement | null) {
if (!img) return null;
const params = img.width > img.height ? { heigth: img.height } : { width: img.width };
if (!img) {
return null;
}
const params = img.width > img.height ? { height: img.height } : { width: img.width };
return <img src={img.src} {...params} alt="" />;
}
@ -80,12 +82,14 @@ function RepeatImageComponent({
if (image) {
setImageSize(image, size);
times(count, () => imagesToRender.push(createImageJSX(image)));
const imgJSX = createImageJSX(image);
times(count, () => imagesToRender.push(imgJSX));
}
if (emptyImage) {
setImageSize(emptyImage, size);
times(max - count, () => imagesToRender.push(createImageJSX(emptyImage)));
const imgJSX = createImageJSX(emptyImage);
times(max - count, () => imagesToRender.push(imgJSX));
}
return (