I've been attempting to apply this transition effect to multiple circles, but only the first one triggers it no matter where they are positioned on the page.
javascript
let circles = document.querySelectorAll('.circle')
circles.forEach(circle => {
circle.addEventListener('mouseenter', () => {
if (!circle.classList.contains('hover')) {
circle.classList.add('hover');
}
})
circle.addEventListener('mouseleave', () => {
if (circle.classList.contains('hover')) {
circle.classList.remove('hover');
}
})
})
css
.circle {
display: flex;
justify-content: center;
align-items: center;
height: 100px;
width: 100px;
background: slateblue;
border-radius: 100px;
font-size: 1.5rem;
color: #fff;
cursor: pointer;
transition: cubic-bezier(0.075, 0.82, 0.165, 1) 3s;
}
.hover {
transform: scale(1.5);
}
html
<div class="circle">1</div>
<div class="circle">2</div>
edit Thank you all for your input, I realized I was overcomplicating things and found a simple solution.