Skip to content

Commit

Permalink
Slow animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete-Fowler committed Sep 9, 2024
1 parent f0890d5 commit ffd0fba
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/components/ui/BlurredShape.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<script>
const blurredShape = document.querySelector('.blurred-shape');

// Get the initial bounding rectangle of the shape
const shapeRect = blurredShape.getBoundingClientRect();
const initialX = shapeRect.left + window.scrollX + (shapeRect.width / 2);
const initialY = shapeRect.top + window.scrollY + (shapeRect.height / 2);
Expand All @@ -35,20 +34,16 @@
let currentX = initialX;
let currentY = initialY;

const easing = 0.02; // Easing factor for smooth movement

// Mouse move handler to update target positions
const easing = 0.01;
document.addEventListener('mousemove', (event) => {
targetX = event.clientX;
targetY = event.clientY;
});

// Animation loop to smoothly move towards the target
function animate() {
currentX += (targetX - currentX) * easing;
currentY += (targetY - currentY) * easing;

// Apply translation based on current position
blurredShape.style.transform = `translate(${currentX - initialX}px, ${currentY - initialY}px)`;

requestAnimationFrame(animate);
Expand Down

0 comments on commit ffd0fba

Please sign in to comment.