Skip to content

Commit

Permalink
prevent hover animation on touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
dwightjack committed Aug 26, 2024
1 parent c811cef commit ef02514
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/Avatar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ import marcoImg from '../assets/images/marco.jpg';
iterations: Infinity,
});

avatar.addEventListener('mouseenter', () => {
animation.updatePlaybackRate(14);
});
if (window.matchMedia('(hover: hover) and (pointer: fine)').matches) {
avatar.addEventListener('mouseenter', () => {
animation.updatePlaybackRate(14);
});

avatar.addEventListener('mouseleave', () => {
animation.updatePlaybackRate(1);
});
avatar.addEventListener('mouseleave', () => {
animation.updatePlaybackRate(1);
});
}
}
}
</script>

0 comments on commit ef02514

Please sign in to comment.