aboutsummaryrefslogtreecommitdiff
path: root/src/component/MosaicBackground.astro
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-08-09 17:23:35 +0200
committerWilliam Hergès <william@herges.fr>2025-08-09 17:23:35 +0200
commitf4c971dc8769f845cc48443dab020cb2e9df661a (patch)
treeb7e38847e663fbd126a5fb875dfb2a0796af71c2 /src/component/MosaicBackground.astro
parent1b763e17ecbe46a3cee806a7177b0bd60e15bf44 (diff)
refactor(background): cleaner and more logical
Diffstat (limited to 'src/component/MosaicBackground.astro')
-rw-r--r--src/component/MosaicBackground.astro15
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`;