Jquery анимация и наведение

я пытаюсь сделать анимацию в jquery,

#wrapper_map div { width:94px; height:265px; float:left; cursor:pointer; position:relative;}
img.main {position: absolute;left:0;top:0;z-index:10;}
img.hover {position:absolute;left:0;top:0;}

<div id="wrapper_map">
     <div class="map1"><a  href="#"><img class="main" src="1.gif" ><img class="hover" src="h_1.gif"></a></div>
    <div class="map2"><a  href="#"><img class="main" src="2.gif" ><img class="hover" src="h_2.gif"></a></div>
    <div class="map3"><a  href="#"><img class="main" src="3.gif" ><img class="hover" src="h_3.gif""></a></div>
    <div class="map4"><a  href="#"><img class="main" src="4.gif" ><img class="hover" src="h_4.gif"></a></div>
    <div class="map5"><a  href="#"><img class="main" src="5.gif" ><img class="hover" src="h_5.gif"></a></div>
</div>

С помощью этой функции img.hover отображается при наведении. Это первая рабочая часть.

$("#wrapper_map img.main").hover(function() {
        $(this).animate({"opacity": "0"},100);
    }, function() {
        $(this).animate({"opacity": "1"},100);
});

Теперь я хотел бы сделать бесконечную анимацию:

Show then hide ".map1 img.hover" when it's finish,
Show then hide ".map2 img.hover" when it's finish,
Show then hide ".map3 img.hover" when it's finish,
Show then hide ".map4 img.hover" when it's finish,
Show then hide ".map5 img.hover" when it's finish, resart the animation.

Но мне нужно, чтобы при наведении курсора мыши на div (.map1, .map2 и т. д.) отображалось наведение класса img на div. Когда мышь выйдет из div wrapper_map, перезапустите бесконечную анимацию.

Я очень хочу сделать что-то подобное, но мне нужна помощь, пожалуйста!

Большое спасибо


person user1085432    schedule 07.12.2011    source источник


Ответы (2)


Функция Jquery http://api.jquery.com/animate/ имеет параметр complete complete: Функция для вызова после завершения анимации. теперь для бесконечной анимации после завершения анимации вы можете вызвать другую функцию, которая имеет анимацию и так далее, чтобы сделать бесконечную анимацию.

person Ali Nouman    schedule 07.12.2011

Вы можете сделать это :

option.imgs.filter(':visible').hide();
option.imgs.eq(index).show();

затем управляйте индексом++

person china.pingxiang    schedule 07.12.2011