Reputation: 575
In my rails app I have the menu that have to be hidden if mouse was unmooved 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?
Upvotes: 1
Views: 937
Reputation: 14268
You could try introducing a chained .stop()
before .slideUp()
and .slideDown()
, which stops any previous animations and will animate from the current position.
Upvotes: 1