diff options
| author | William Hergès <william@herges.fr> | 2025-08-09 17:06:06 +0200 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2025-08-09 17:06:06 +0200 |
| commit | e5c92241cf23546e8fdccd92050c02516f0abd9a (patch) | |
| tree | ba9d2717443cb0e78c7ee31c0de7729f4871e393 /src/component/MosaicBackground.astro | |
| parent | 8f826e1843fcfd210fa036196a9efa4a4f7fe144 (diff) | |
feat(content): scroll animation
Diffstat (limited to 'src/component/MosaicBackground.astro')
| -rw-r--r-- | src/component/MosaicBackground.astro | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/component/MosaicBackground.astro b/src/component/MosaicBackground.astro index d568172..df81a25 100644 --- a/src/component/MosaicBackground.astro +++ b/src/component/MosaicBackground.astro @@ -13,8 +13,8 @@ const { height = "400" } = Astro.props; const children = e.children; const max = e.clientWidth; const height = e.getAttribute("data-height"); + if (height == null) throw new Error(`Height is null`); const newChildren = []; - console.log(e.hasAttribute("data-height")); let line = document.createElement("div"); let currentWidth = 0; @@ -22,7 +22,6 @@ const { height = "400" } = Astro.props; const fn = () => { let current = children[i++]; - console.log(current.getBoundingClientRect().width, current.getBoundingClientRect().height); let ratio = current.clientWidth / current.clientHeight; line.appendChild(current.cloneNode(true)); currentWidth += ratio * height; @@ -33,10 +32,8 @@ const { height = "400" } = Astro.props; while (i < children.length && currentWidth <= max) fn(); if (i < children.length) fn(); // setting height - console.log(currentWidth); let h = (max * height) / currentWidth; - console.log(`${h}px`); - line.style.height = `${h - 1}px`; + line.style.height = `${h - 0.01}px`; newChildren.push(line); if (i < children.length) { line = document.createElement("div"); |
