Skip to content

Commit

Permalink
Draft animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete-Fowler committed Sep 7, 2024
1 parent b8d4186 commit 32cff8e
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/components/ui/BlurredShape.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,32 @@
}

}
</style>
</style>

<script>
const blurredShape = document.querySelector('.blurred-shape');

let mouseX = 0;
let mouseY = 0;
let shapeX = 0;
let shapeY = 0;
const easing = 0.05;

document.addEventListener('mousemove', (event) => {
mouseX = event.clientX;
mouseY = event.clientY;
});


function animate() {
shapeX += (mouseX - shapeX) * easing;
shapeY += (mouseY - shapeY) * easing;

blurredShape.style.transform = `translate(${shapeX}px, ${shapeY}px)`;

requestAnimationFrame(animate);
}

animate();

</script>

0 comments on commit 32cff8e

Please sign in to comment.