2012-01-20 2 views
0

시행 흔들림을 작동하지 I는 jQuery 코드 가지고의 jQuery .stop()는 호버

setInterval(function() { 

    var grayarrow = jQuery("ul#dropdowngray").parent(); 
    var greenarrow = jQuery("ul#dropdown").parent(); 

    grayarrow.effect('shake', { times:2 }, 100); 
    greenarrow.effect('shake', { times:3 }, 200); 

    jQuery("ul#dropdowngray").parent().hover( 

     function(){ grayarrow.stop().effect('shake', { times:0 }, 100); }, 

     function(){ grayarrow.stop().effect('shake', { times:2 }, 100); } 

    ); 

    jQuery("ul#dropdown").parent().hover( 

     function(){ greenarrow.stop().effect('shake', { times:0 }, 100); }, 

     function(){ greenarrow.stop().effect('shake', { times:2 }, 100); } 

    ); 

}, 5000); 

이펙트 보려면 : I가 요소 가리키면 그러나 http://mainstreetfinancing.com.s136249.gridserver.com/frequently-asked-questions-direct-lender-net-lender.html

을 흔들림이 계속 실행 . jquery .stop() not working

을 마우스를 흔들어 요소 위에있을 때 나는 효과적으로 흔들어 정지를 할 수있는 방법이 어느 작동하지 이후, 나는이 솔루션은 여기서 논의 구현,

jQuery("ul#dropdowngray").parent().hover( 

      function(){ grayarrow.stop(); }, 

      function(){ grayarrow.stop(); } 

     ); 

하지만 : 원래, 나는 코드를했다 ? http://api.jquery.com/stop/를 참조 정지에() 호출을

답변

2

는 2 argements (사실 : 사실, jumpToEnd clearQueue)을 통과해야 즉시 중지하려면, 감사합니다. 또한 마우스를 요소에 올리면 즉시 반환해야하도록 setInterval 호출을 제어하는 ​​변수를 설정해야합니다. 여기에 코드가 있습니다. 효과를 확인하려면 http://jsfiddle.net/BT4bt/

var stopShaking = false; 


var shakeIt = function() { 
    $('#shaker').effect('shake', { times: 6 }, 100); 
} 

setInterval(function() { 
    if (stopShaking) { 
     return; 
    } 
    shakeIt(); 
}, 5000); 

$('#shaker').hover(function(){ 
    $(this).stop(true, true); 
    stopShaking = true; 
}, function(){ 
    stopShaking = false; 
}) 
+0

으로 문의하십시오. 그것은 정말 잘 작동합니다. 고맙습니다 – IberoMedia