开发者

detect if user hovers for period of time in jQuery

I'm using this animate jQuery code:

                $('.tabs').hover(
                    function(){
                        $('#tabs-wrap').animate({marginTop: '+=147'}, 500);
                        $('.tabs li a').delay(250).animate({height: '150'}, 500);
                    },
                    function(){
                        $('.tabs li a').animate({height: '40'}, 500);
                        $('#tabs-wrap').delay(250).animate({marginTop: '-=147'}, 500);
                    }
                );  

But is it possible to only start animating if the user has the mouse hovered for a certain amount of time (to stop the effect if the they just swipe the mouse of rather than intentionally activating it)

开发者_开发知识库

Thanks!


Check out the hoverIntent plugin, basically it uses setTimeout to invoke the function after x millseconds, the timeout is cancelled if they user mouse outs.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜