2017-01-22 3 views
0

私はこの問題の解決策を見つけることができません。何が起こっているのは、mouseleaveをトリガーし、mouseleaveからfadeOut()までの期間内にマウスオーバーをトリガーしようとすると、マウスオーバーがトリガーされないということです。これを修正する方法はありますか、またはjqueryのアニメーション機能を使用する必要がありますか?あなたのケースではJQueryマウスを離し、mouseleaveに設定したfadeOutの時間内でマウスオーバーします

$("#homepage-slider").on({ 
    mouseover: function() { 
     $(".direction-next").fadeTo(500, .7); 
     $(".direction-previous").fadeTo(500, .7); 
    }, 
    mouseleave: function() { 
     $(".direction-next").fadeOut(500); 
     $(".direction-previous").fadeOut(500); 
    } 
}); 

答えて

1

は、あなたがstopにアニメーション、clear the queue、その後jump to the endが必要になります。

どうすればよいですか? jQueryの.stop(true,true)を利用します。

$("#homepage-slider").on({ 
    mouseover: function() { 
     $(".direction-next").stop(true, true).fadeTo(500, .7); 
     $(".direction-previous").stop(true, true).fadeTo(500, .7); 
    }, 
    mouseleave: function() { 
     $(".direction-next").fadeOut(500); 
     $(".direction-previous").fadeOut(500); 
    } 
}); 

obligatory jsFiddle

関連する問題