From e5c92241cf23546e8fdccd92050c02516f0abd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Sat, 9 Aug 2025 17:06:06 +0200 Subject: feat(content): scroll animation --- src/component/MosaicBackground.astro | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/component') 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"); -- cgit v1.2.3