Hover over a box and I’ll explain it! 🗨️
Dive Trips
Courses
Accommodation
document.addEventListener('DOMContentLoaded', () => {
const character = document.querySelector('.character');
const speech = document.getElementById('speech');
const boxes = document.querySelectorAll('.box');
if (!character || !speech) return;
document.addEventListener('mousemove', (e) => {
const x = e.clientX;
const y = e.clientY;
character.style.transform = `translate(${x - 40}px, ${y - 40}px)`;
speech.style.transform = `translate(${x - 40}px, ${y - 120}px)`;
});
boxes.forEach(box => {
box.addEventListener('mouseenter', () => {
speech.textContent = box.getAttribute('data-text');
});
box.addEventListener('mouseleave', () => {
speech.textContent = 'Hover over a box and I’ll explain it! 🗨️';
});
});
});