-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
24 lines (20 loc) · 761 Bytes
/
index.js
File metadata and controls
24 lines (20 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const buttonContainers = document.querySelectorAll('.button-container');
buttonContainers.forEach((container) => {
const lottiePlayer = container.querySelector('dotlottie-player');
// Stop then start animation
container.addEventListener('mouseenter', () => {
lottiePlayer.stop();
lottiePlayer.play();
});
// Reset the animation to the beginning, then start
lottiePlayer.addEventListener('complete', () => {
if (container.matches(':hover')) {
lottiePlayer.seek(0); // Reset the animation to the beginning
lottiePlayer.play(); // Play the animation
}
});
// Stop the animation
container.addEventListener('mouseleave', () => {
lottiePlayer.stop();
});
});