Note that there are some explanatory texts on larger screens.

plurals
  1. POHover animation in navigation being blocked if it touches the mouse
    primarykey
    data
    text
    <p>Firstly apologies for the terrible title. Couldn't think of a better way to word it.</p> <p>Secondly this bug does not seem to be happening for me in Chrome, but it is in Firefox and I have not tested any other browsers.</p> <p>What I am trying to achieve is an on hover animation for my menu items, where brackets envelop the menu item as you hover over them, however my mouse appears to be blocking the animation.</p> <p>I understand why - it is because as soon as my mouse touches the bracket, it is no longer hovering the nav item, so it is triggering the mouseleave function. Problem is I have absolutely no idea how to prevent this.</p> <p>HTML</p> <pre><code>&lt;nav&gt; &lt;ul&gt; &lt;li class="active"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;News&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Projects&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;div id="navHoverLeft"&gt;[&lt;/div&gt; &lt;div id="navHoverRight"&gt;]&lt;div&gt; </code></pre> <p>CSS</p> <pre><code>nav{ background-color: rgba(0,0,0,0.6); width: 100%; overflow: hidden; margin-bottom: 10px; } nav ul{ position: relative; float: left; left: 50%; } nav li{ position: relative; float: left; right: 50%; list-style: none; margin: 15px 25px 0 15px; } nav a{ color: #fff; } nav a:hover{ text-decoration: none; color: #fff; } #navHoverLeft, #navHoverRight{ position: fixed; z-index: 500; color: #f33; float: left; } </code></pre> <p>Javascript/jQuery</p> <pre><code> $(document).ready(function(){ $('#navHoverLeft').css('top', $('nav ul li.active').offset().top - 1); $('#navHoverLeft').css('left', $('nav ul li.active').offset().left - 13); $('#navHoverRight').css('top', $('nav ul li.active').offset().top - 1); $('#navHoverRight').css('left', $('nav ul li.active').offset().left + $('.active').width() + 3); $('nav ul li a').on('mouseenter', function(){ $('#navHoverLeft').animate({ "left" : $(this).parent().offset().left - 13 }, 500).clearQueue(); $('#navHoverRight').animate({ "left" : $(this).parent().offset().left + $(this).parent().width() + 3 }, 500).clearQueue(); }); $('nav ul li a').on('mouseleave', function(){ $('#navHoverLeft').animate({ "left" : $('.active').offset().left - 13 }, 500).clearQueue(); $('#navHoverRight').animate({ "left" : $('.active').offset().left + $('.active').width() + 3 }, 500).clearQueue(); }); }); </code></pre> <p>Here is a <a href="http://jsfiddle.net/RCG8q/" rel="nofollow" title="fiddle">fiddle</a> of it all together.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload