Check out this plugin:
http://cherne.net/brian/resources/jquery.hoverIntent.html
It may help you.
Instead of mouseenter and leave do
$('object').hoverIntent(function(){
$("ul.LvlTwo").slideToggle('medium');
},function(){
setTimeout(function () {
$("ul.LvlTwo").slideToggle('
>
> medium');
> }, 2000);
});
2009/6/2 zayatzz <[email protected]>
>
> Thanks.
>
> I did that:
>
> <script type="text/javascript">
> $(document).ready(function () {
> $("ul.LvlOne
> li:has(ul)").bind("mouseenter",function(event){
> $("ul.LvlTwo").slideToggle('medium');
> });
> $("ul.LvlOne
> li:has(ul)").bind("mouseleave",function(event){
> setTimeout(function () {
>
> $("ul.LvlTwo").slideToggle('medium');
> }, 2000);
> });
> });
> </script>
>
> Even with 4 second or longer delay it starts flashing at some point.
>
> It actually became worse, because now you have 2 seconds to get your
> mouse cursor back to where menu is supposed to be so you have even
> more chances for the menu to start jumping up and down, closed -
> open...
>
> Perhaps there should be somekind of doublecheck at mouseleave event
> that checks if the mouseenter on same element havent fired already?
>
> Alan.
>
> On Jun 2, 8:33 pm, Gustavo Salomé <[email protected]> wrote:
> > Try the setTimeout function
> >
> > 2009/6/2 zayatzz <[email protected]>
> >
> >
> >
> >
> >
> > > Hello
> >
> > > Is it possible to mouseleave event have some kind of delay inserted
> > > into it?
> >
> > > I have this small script, which is working just fine :
> >
> > > <script type="text/javascript">
> > > $(document).ready(function () {
> > > $("ul.LvlOne
> > > li:has(ul)").bind("mouseenter",function(event){
> > > $("ul.LvlTwo").slideToggle('medium');
> > > });
> > > $("ul.LvlOne
> > > li:has(ul)").bind("mouseleave",function(event){
> > > $("ul.LvlTwo").slideToggle('medium');
> > > });
> > > });
> > > </script>
> >
> > > The problem is that the menu that opens is quite long and visitors of
> > > the site (me among them) move cursor down where menu is supposed to
> > > end up when its fully opened, but since the menu has not reached this
> > > far, the mouseleave event fires. When computer or browser is slow you
> > > can see even stranger thing.
> >
> > > Menu gets mouseleave event and starts closing, but not before menu
> > > reaches the cursor. That means the menu gets mouseleave, then
> > > mouseenter, does not reach cursor before mouseleave event fires, then
> > > gets mouseenter again and keeps closing/opening/closing/opening/
> > > closing/opening forever.
> >
> > > So what i want to know, if it is possible to insert some kind of
> > > delays or doublechecks into the system to stop this kind of stuff from
> > > happening or should i just tell everybody to slow down their mouse
> > > movement?
> >
> > > Alan
> >
> > --
> > Gustavo Salome Silva
>
--
Gustavo Salome Silva