diff options
Diffstat (limited to 'src/component/MosaicBackground.astro')
| -rw-r--r-- | src/component/MosaicBackground.astro | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/component/MosaicBackground.astro b/src/component/MosaicBackground.astro index df81a25..c8e01f5 100644 --- a/src/component/MosaicBackground.astro +++ b/src/component/MosaicBackground.astro @@ -20,17 +20,14 @@ const { height = "400" } = Astro.props; let currentWidth = 0; let i = 0; - const fn = () => { - let current = children[i++]; - let ratio = current.clientWidth / current.clientHeight; - line.appendChild(current.cloneNode(true)); - currentWidth += ratio * height; - }; - while (i < children.length) { // adding elements - while (i < children.length && currentWidth <= max) fn(); - if (i < children.length) fn(); + while (i < children.length && currentWidth <= max) { + let current = children[i++]; + let ratio = current.clientWidth / current.clientHeight; + line.appendChild(current.cloneNode(true)); + currentWidth += ratio * height; + } // setting height let h = (max * height) / currentWidth; line.style.height = `${h - 0.01}px`; |
