I have this line of thumbnails that I am animating using jQuery.
Each of these thumbnails has a hover and an active class.
They work fine, but when I animate the list, a new thumbnail under my arm doesnโt apply hovering? Do I need to move the mouse a little after each click?
Itโs hard to exaggerate .. I made a fiddle here: http://jsfiddle.net/nZGYA/
When you start clicking after thumb 3 without moving the mouse, you see what I mean ...
It works great in FireFox, NOT Safari, Chrome, IE, etc.
Is there anything I can do about this?
For reference, here is my code:
<style type="text/css"> .container { position: relative; overflow: hidden; width: 140px; height: 460px; float: left; margin-right: 100px; background: silver; } ul { position: absolute; top: 10; list-style: none; margin: 10px; padding: 0; } li { margin-bottom: 10px; width: 120px; height: 80px; background: gray; } #list-2 li a { display: block; width: 120px; height: 80px; outline: none; } #list-2 li a:hover { background: teal; } #list-2 li a.active { background: navy; } </style> $(document).ready(function() { var idx_2 = 0; $('#list-2 li a') .click(function() { $('#list-2 > li a').removeClass('active'); $(this).addClass('active'); var id = $('#list-2 li a.active').data('index') - 2; idy = Math.max(0, id * 90); $(this).parent().parent().animate({ 'top' : -idy + 'px' }); return false; }) .each(function() { $(this).data('index', idx_2); ++idx_2; }); }); <div class="container"> <ul id="list-2"> <li><a class="active" href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> <li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li><li><a href="#"></a></li> </ul> </div>
Ffish
source share