Skip to content

Commit

Permalink
[Canvas] Repeat image bug with image height fixed. (#121497) (#121895)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Kuznietsov authored Dec 22, 2021
1 parent 9511545 commit 63bac2e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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="" />;
}

Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 63bac2e

Please sign in to comment.