Hello there! I am facing an issue with a small project I'm working on. My goal is to have an indicator appear whenever I hover my mouse over the fishing area, but it seems like the coordinates are off when using the mousemove event. You can check out my code on this link.
HTML
<div class="game-content">
<div class="pond">
<div id="circle" class="circle"></div>
<div id="pond__fishing-area" class="pond__fishing-area"></div>
</div>
</div>
JS
new Vue({
el: '#app',
mounted() {
let circle = document.getElementById("circle");
let circleRect = circle.getBoundingClientRect();
let wrapper = document.getElementById("pond__fishing-area");
let wrapperRect = wrapper.getBoundingClientRect();
function moveCircle(e) {
gsap.to(circle, 0.3, {
css: {
left: e.clientX,
top: e.clientY
}
});
}
wrapper.addEventListener("mouseover", function() {
gsap.to(circle, 0.4, { scale: 1, autoAlpha: 1 });
wrapper.addEventListener("mousemove", moveCircle);
});
wrapper.addEventListener("mouseout", function() {
gsap.to(circle, 0.4, { scale: 0.1, autoAlpha: 0 });
});
}
})