動畫集錦(P2)

範例結果

三、【.movie】照片輪播,並且滑鼠移入時,停止輪播

    //S4:.movie 定時輪播
    var _speed = 3000;
    var $timer=window.setTimeout(sliderTimeFn,_speed);

      //.movie滑鼠移入時,停止輪播
        $('.movie').hover(
          function(){ window.clearTimeout($timer);}
          ,function(){ $timer = window.setTimeout(sliderTimeFn,_speed);}
        );

      //.movie 輪播fn
        function sliderTimeFn(){
          var $clickIndex = $('.movie .title li.on').index();
          $clickIndex = ($clickIndex+1) % $('.title li').length;
          $('.title li').eq($clickIndex).click();
          $timer = window.setTimeout(sliderTimeFn,_speed);
        }