6
Is there a way, alternative, more lite, to superfish, to delay the closing of a dropdown menu? When the menu is at Hover, it obviously opens, and when the mouse is no longer focused on it, the menu closes. Like to have a delay in closing this menu. Something similar to superfish.
PS EDIT
I found something similar to what is asked in the question, with some considerations. It is the Unhover Intent in JS CSS-TRICKS works to a certain extent. It doesn’t work with more than one dropdown. What can be done to make it more efficient is: Dropdown must maintain delay, including in the dropdown dropdown. But the delay should end if the mouse moves to another main Nav item.
#primary_nav_wrap
{
margin-top:15px
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:#f6f6f6
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
float:none;
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item"><a href="#">Home</a></li>
<li class="has-children"><a href="#">Sub Menu 2</a>
<ul class="sub-menu">
<li><a href="#">Schiller</a></li>
<li><a href="#">Gogol</a></li>
<li><a href="#">Nietzsche</a></li>
<li class="has-children"><a href="#">Schoppenhauer</a>
<ul class="sub-menu">
<li><a href="#">Linspector</a></li>
<li><a href="#">Shakespeare</a></li>
<li><a href="#">Andrade</a></li>
<li class="has-children"><a href="#">Code Geass</a>
<ul class="sub-menu">
<li><a href="#">Shingeki No Kyojin</a></li>
<li><a href="#">Shisekai yori</a></li>
<li><a href="#">No game no life</a></li>
<li><a href="#">One Punch Man</a></li>
<li><a href="#">Nanatsu no Tasai</a></li>
</ul>
</li>
<li><a href="#">Tolstói</a></li>
<li><a href="#">Platão</a></li>
</ul>
</li>
<li><a href="#">Dostoievski</a></li>
<li><a href="#">Immanuel Kant</a></li>
</ul>
</li>
<li><a href="#">Deep Menu</a>
<ul>
<li><a href="#">Sub Menu 1</a></li>
<li><a href="#">Sub Menu 2</a></li>
<li><a href="#">Sub Menu 3</a></li>
<li><a href="#">Sub Menu 4</a>
<ul>
<li><a href="#">Deep Menu 1</a>
<ul>
<li><a href="#">Sub Deep 1</a></li>
<li><a href="#">Sub Deep 2</a></li>
<li><a href="#">Sub Deep 3</a></li>
<li><a href="#">Sub Deep 4</a></li>
</ul>
</li>
<li><a href="#">Deep Menu 2</a></li>
</ul>
</li>
<li><a href="#">Sub Menu 5</a></li>
</ul>
</li>
<li><a href="#">Menu 2</a>
<ul>
<li><a href="#">Sub Menu 1</a></li>
<li><a href="#">Sub Menu 2</a></li>
<li><a href="#">Sub Menu 3</a></li>
</ul>
</li>
<li><a href="#">Menu 3</a>
<ul>
<li class="dir"><a href="#">Sub Menu 1</a></li>
<li class="dir"><a href="#">Sub Menu 2 THIS IS SO LONG IT MIGHT CAUSE AN ISSEUE BUT MAYBE NOT?</a>
<ul>
<li><a href="#">Category 1</a></li>
<li><a href="#">Category 2</a></li>
<li><a href="#">Category 3</a></li>
<li><a href="#">Category 4</a></li>
<li><a href="#">Category 5</a></li>
</ul>
</li>
<li><a href="#">Sub Menu 3</a></li>
<li><a href="#">Sub Menu 4</a></li>
<li><a href="#">Sub Menu 5</a></li>
</ul>
</li>
</ul>
</nav>
References
https://codepen.io/team/css-tricks/pen/myLByd
https://css-tricks.com/dropdown-menus-with-more-forgiving-mouse-movement-paths/
http://benalman.com/code/projects/jquery-dotimeout/examples/hoverintent/#1b
Have you tried using the
transition
specifying the delay as in this example? It doesn’t work for you?– Diego Rafael Souza
@Diegorafaelsouza I have tried this, but it is not as efficient, unless it is with some conditionals. The dropdown delay should end. The moment the mouse is moved to another navigation item.
– John Quimera