Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const container = document.querySelector('.shape-container');
+ const shapes = [];
+ const numShapes = 15;
+
+ // Create initial shapes
+ for (let i = 0; i < numShapes; i++) {
+ createShape();
+ }
+
+ function createShape() {
+ const shape = document.createElement('div');
+ shape.className = 'shape';
+ const size = Math.random() * 200 + 100;
+
+ const shapeStyle = {
+ width: `${size}px`,
+ height: `${size}px`,
+ left: `${Math.random() * 100}%`,
+ top: `${Math.random() * 100}%`,
+ opacity: Math.random() * 0.5 + 0.1
+ };
+
+ Object.assign(shape.style, shapeStyle);
+ container.appendChild(shape);
+ shapes.push(shape);
+ }
+
+ // Handle mouse/touch movement
+ function handleMovement(e) {
+ const x = e.clientX || e.touches[0].clientX;
+ const y = e.clientY || e.touches[0].clientY;
+
+ shapes.forEach((shape, index) => {
+ const rect = shape.getBoundingClientRect();
+ const centerX = rect.left + rect.width / 2;
+ const centerY = rect.top + rect.height / 2;
+
+ const deltaX = (x - centerX) / 20;
+ const deltaY = (y - centerY) / 20;
+
+ const distance = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
+ const scale = Math.max(0.8, 1 - distance / 1000);
+
+ shape.style.transform = `translate(${deltaX}px, ${deltaY}px) scale(${scale})`;
+ });
+ }
+
+ // Event listeners
+ document.addEventListener('mousemove', handleMovement);
+ document.addEventListener('touchmove', handleMovement);
+
+ // Reset shapes on mouse/touch end
+ function resetShapes() {
+ shapes.forEach(shape => {
+ shape.style.transform = 'translate(0, 0) scale(1)';
+ });
+ }
+
+ document.addEventListener('mouseleave', resetShapes);
+ document.addEventListener('touchend', resetShapes);
+ });