开发者

jQuery slideUp and slideDown problem

In my rails app I have the menu that have to be hidden if mouse was unmooved 开发者_Python百科for 5 seconds. It works fine with .hide() and .show(), but with .slideDown() and .slideUp() it starts to sliding up very fast, than sliding down and so on. Is there another approach to them? Here is my code:

$(document).ready(function(){
var i = null;
$("#all").mousemove(function() {
    clearTimeout(i);
    $(this).css("cursor", "default");
    $("#menu").show();
    i = setTimeout('$("#menu").hide();$("#flash_notice").hide(); $(this).css("cursor", "none");', 5000);
}).mouseleave(function() {
    clearTimeout(i);
    $("#flash_notice").hide();
        $("#menu").hide();
    $(this).css("cursor", "none");

}); });

Another issue is with $(this).css("cursor", "none");, it's seems to be working, but from time to time, so I'm really confused, what should I do. Thank you in advance for any tip. Anyone?


You could try introducing a chained .stop() before .slideUp() and .slideDown(), which stops any previous animations and will animate from the current position.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜