开发者

jQuery: Easy way to trigger "mousestop" event

HI,

I'm trying to call a function when the mouse stopped moving for x seconds. Actually thats pretty easy with the following code:

var timer = null;
$(document).mousemove(function(){
  clearTimeout (timer);
  timer = setTimeout(myfunction, 5000);
});

But the mousemove开发者_Python百科 event is called very often, so I get a pretty heavy processor load in Firefox while moving the mouse. Is there an easy way to do the same thing with less function calls???

Thanx! Jan


Use this and set the delay option for x seconds

http://www.richardscarrott.co.uk/posts/view/jquery-mousestop-event


Take a look at the jQuery hoverIntent plugin

Usage is the same as jQuery hover, but the event only fires after a short, configurable delay.

$('myselector').hoverIntent(
        function () { HoverIn(); },
        function () { HoverOut(); }
);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜