2011-08-04 9 views
0

a web site 페이지가로드 될 때 자동으로 슬라이드하는 jQuery 슬라이더가 있습니다. 마우스를 움직일 때 슬라이더를 멈추게하려면 어떻게합니까?마우스를 가져 가면 JQuery 슬라이더가 중지됩니다.

var my_jQuery = jQuery.noConflict(true); 

    window.onload = function() { 

     // added by pesach 

     var totalWidth=0; 
     var numItems=0; 
     my_jQuery('li', 'div#scroll_Bar').each (function() { 

     totalWidth = totalWidth + my_jQuery(this).outerWidth() + 1; 
     numItems = numItems + 1; 

     }); 
     //alert(totalWidth * -1); 

     my_jQuery('ul', 'div#scroll_Bar').width(totalWidth); 
     var slidewidth = totalWidth - 960; 
     //end of addition 


     var container = $('div#scroll_Bar'); 
     var ul = $('ul', container); 

     var itemsWidth = ul.innerWidth() - container.outerWidth(); 

     //$("div.sliderGallery ul li").hover(stop(true, true), stop(true, true)); 
     my_jQuery('ul', 'div#scroll_Bar').animate({'left' : slidewidth * -1}, numItems * 1000, 'linear'); 
     my_jQuery('ul', 'div#scroll_Bar').animate({'left' : 0}, numItems * 800, 'linear'); 


     my_jQuery('.slider', container).slider({ 
      min: 0, 
      max: itemsWidth, 
      handle: '.handle', 
      stop: function (event, ui) { 
       ul.animate({'left' : ui.value * -1}, 500),my_jQuery('ul', 'div#scroll_Bar').stop(true, true); 
      }, 
      slide: function (event, ui) { 
       ul.css('left', ui.value * -1),my_jQuery('ul', 'div#scroll_Bar').stop(true, true); 
      } 
     }); 

    }; 

답변

1

아마도 .stop()를 사용하여 명령을

나는 다음과 같은 jQuery 코드를 사용하고 있습니다? 당신이 개 애니메이션 선 후 그래서

: 또한

my_jQuery('ul','#scoll_Bar').mouseover(function(){ 
    $(this).stop(); 
}); 

는, ID가 요소 전에 div를 가진 아무 소용 없다, 그래서 그들을 제거 :
사업부 #scroll_Bar는

+0

을 주셔서 감사합니다 당신의 응답. 코드를 입력 한 후에 마우스를 올려 놓으면 멈추지 않습니다. 당신은 (나는 코드를 추가) 링크를 확인할 수 있습니다. 추가 제안 사항이 있으면 크게 감사하겠습니다. 미리 감사드립니다. – pzirkind

관련 문제