2009-07-26 3 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(); 
      } 
    ); 
}); 

は、私が使用してみましたhoverIntentプラグインをロードしてこのように使用しても動作していないようですが、動作していないようです:

$(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(); 

        } 
     ); 

}); 

代替案を指摘していますか? おそらく、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

関連する問題