From bb40e21115adfe4f48f369b43dfd8a2179648ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Ekstr=C3=B6m?= Date: Tue, 7 Nov 2023 16:11:57 +0100 Subject: [PATCH] Fix width setting in wrong order --- src/containers/App.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/containers/App.js b/src/containers/App.js index f68a735..a2095eb 100644 --- a/src/containers/App.js +++ b/src/containers/App.js @@ -20,20 +20,24 @@ function App() { if (squares.length > 0) { squares.forEach((square) => { - if (square.classList.contains('square-h')) { - square.style.width = square.scrollHeight + 'px'; - } - if (square.classList.contains('square-h-half')) { square.style.width = (square.scrollHeight / 2) - 10 + 'px'; + return; } - if (square.classList.contains('square-w')) { - square.style.width = square.scrollWidth + 'px'; + if (square.classList.contains('square-h')) { + square.style.width = square.scrollHeight + 'px'; + return; } if (square.classList.contains('square-w-half')) { square.style.width = (square.scrollWidth / 2) - 10 + 'px'; + return; + } + + if (square.classList.contains('square-w')) { + square.style.width = square.scrollWidth + 'px'; + return; } }); }