0
I’m using Animate.css to zoom in on an image. The idea is that the animation only works with the Hover/mouseenter, that is, when the user hovers over it. When I use any animation other than zoomIn, it works normally; however, with the code below, although the zoom works, the image is blinking when I hover the mouse in certain places. If I shoot the . mouseout, the event only occurs once. What to do to resolve?
<img src="imagens/icone.png" class="hover" />
<script>
$(document).ready(function() {
$('.hover').mouseenter(function() {
var mv = $(this);
mv.addClass('animated zoomIn');
});
$('.hover').mouseout(function(){
var mv = $(this);
mv.removeClass('animated zoomIn');
});
});
</script>
Hello Rafaela, this happens because when zoomIn class is added the image is resized from Scale(0) to Scale(1). In this transformation, the image is so small that the mouse comes out of it. Actually the image that comes out of the mouse. Then the second mouseout event is triggered, causing the image to return to Scale(1) again. Then when you touch the mouse, the first function is triggered and this is in an infinite loop. I’m trying to think of a solution for you.
– Andrew Ribeiro
got it. It makes perfect sense, since it just doesn’t work THAT animation and with the Hover. Other animations and other means of making it work (click and scroll, for example), work normally.
– Rafaela Lopes