2009-07-26 5 views
0

div에서 마우스를 가져 가면 약간의 지연이 발생하여 sIFR 텍스트가 표시되도록하려고합니다.jQuery 및 sIFR. 마우스 오버시 지연 및 표시

마크 업이처럼, 여러 번 :

<div class="box"> 
    <div class="text"> 

     <h6>sIFR Text</h6> 

    </div> 
</div> 

이 코드는 (호버에 또는 sIFR에 숨기기에서) 트릭을하고 있지만, 지체없이 :

$(document).ready(function() {  

     $('.text').hide(); 

     $('.box').mouseover(

     function() { 

       $(this).children('.text').show(); 

       //sIFR code : 
        sIFR.replace(rockwell, { 
          selector: 'h6', 
         css: [ 
          '.sIFR-root { color:#FFFFFF; font-size: 1.2em; text-transform: uppercase }', 
          'a {color: #333333; text-decoration: none;}', 
          'a:hover {color: #333333;text-decoration:underline;}' 
          ], wmode: "transparent" 
        } 
        ); //sIFR ends 

     }); 



     $('.box').mouseout(

     function() { 
       $(this).children('.text').hide(); 
      } 
    ); 
}); 

내가 사용하려고 당신은 할 수

$(document).ready(function() {   

     $('.text').hide(); 

     $('.box').hoverIntent(

       function() { 

        $(this).children('.text').show(); 

     //sIFR code should go here 
        sIFR.replace(rockwell, { 
          selector: 'h6', 
         css: [ 
          '.sIFR-root { color:#FFFFFF; font-size: 1.2em; text-transform: uppercase }', 
          'a {color: #333333; text-decoration: none;}', 
          'a:hover {color: #333333;text-decoration:underline;}' 
          ], wmode: "transparent" 
        } 
        ); //sIFR ends 

       }, 

       function(){ 

        $(this).children('.text').hide(); 

        } 
     ); 

}); 

다음 hoverIntent 플러그인을로드하고,이처럼 사용하지만 작동하는 것 같다하지 않습니다 대안을 지적 해 주시겠습니까? 아마도 setTimeout은 좋은 대안이지만, 전에 사용 해본 적이 없으며 어디에 넣어야하는지 잘 모르겠습니다.

팁 주셔서 감사합니다.

답변

1

setTimeout을 사용할 수 있습니다.

$(document).ready(function() {   

     //delcare a variable to hold the timeout 
     var to; 

     $('.text').hide(); 

     $('.box').mouseover(

       function() { 

        $(this).children('.text').show(); 

        // do sIFR code after 1000 milliseconds 
        to = setTimeout(function() { /* sIFR code goes here */ }, 1000); 

       }); 



     $('.box').mouseout(

       function() { 
         // If mouseout happens before the delay ends 
         // you probably don't want sIFR code to run. 
         clearTimeout(to); 


         $(this).children('.text').hide(); 
       } 
     ); 
}); 
+0

감사합니다. – Peanuts

관련 문제