Skip to content

Commit

Permalink
Made Abstract Particle Swarm Background component responsive (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhoenix08 authored Dec 23, 2024
1 parent 200cd30 commit 1429e6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
let canvasRect = canvas.getBoundingClientRect();
canvas.width = canvasRect.width;
canvas.height = canvasRect.height;

const colors = ['#FF5733', '#FFBD33', '#33FF57', '#33C5FF', '#7A33FF', '#FF33E9', '#FFE233'];

Expand Down Expand Up @@ -55,3 +56,9 @@ function animate() {
}

animate();

window.addEventListener('resize', function() {
canvasRect = canvas.getBoundingClientRect();
canvas.width = canvasRect.width;
canvas.height = canvasRect.height;
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
body {
margin: 0;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}

canvas {
display: block;
background-color: black;
width: 100vw;
height: 100vh;
}

0 comments on commit 1429e6e

Please sign in to comment.