Skip to content

Commit

Permalink
Fix width setting in wrong order
Browse files Browse the repository at this point in the history
  • Loading branch information
didair committed Nov 7, 2023
1 parent 092c578 commit bb40e21
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}
Expand Down

0 comments on commit bb40e21

Please sign in to comment.