Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmenu animation "pops up"
    primarykey
    data
    text
    <p>I have a menu with sub items inside it. In order to make animation effect I want, I need to retrieve sub-menu <b>width</b>,<b>height</b> and <b>height of its first-child</b>. Now my animation works ,but sometimes my sub-menu just "pops up" (it doesn't animate its <b>width</b> ). <br/><br/>Here is <b><a href="http://jsfiddle.net/TNxJ4/" rel="nofollow noreferrer">The Fiddle</a></b> of the problem.</p> <p><br/><a href="http://www.vasinternetposao.com/wordpressdevelopment/wp-content/themes/override/images/submenu_problem.png" rel="nofollow noreferrer">http://www.vasinternetposao.com/wordpressdevelopment/wp-content/themes/override/images/submenu_problem.png</a></p> <p>I am using this code:</p> <pre><code>var j = jQuery.noConflict(); j(document).ready(function () { j('ul.nav').removeClass('nav').addClass('jnav'); //Add jquery Class to our menu j('ul.jnav li').hover(function () { if (j(this).children('ul:first').hasClass('jsub-menu')) { //Let's check if "jsub-menu" Class is here return false; //If it is ("jsub-menu" here) don't SlideDown... } else { //Else slide down if no class j(this).find('ul.sub-menu:first').not(':animated').slideDown(500); } }, function () { j(this).find('ul:first').slideUp(500, function () { j(this).removeClass('jsub-menu').addClass('sub-menu'); j(this).css({ 'height': '', 'width': '' }); }); }); j('ul.jnav ul.sub-menu a').hover(function () { j(this).addClass('active'); if (j('.active').next('ul.sub-menu').length) { //If submenu exist... j('.active').next('ul.sub-menu').css({ 'visibility': 'hidden', 'opacity': '0', 'display': 'block' }); //Show it so we can read its: var get_width = j('.active').next('ul.sub-menu').outerWidth(true); //WIDTH var get_height_of_first_child = j('.active').next('ul.sub-menu').children('li:first').outerHeight(true); //HEIGHT of its First Child var get_submenu_height = j('.active').next('ul.sub-menu').outerHeight(true); //HEIGHT of our menu j('.active').next('ul').removeClass('sub-menu') //Remove class from menu, add another class apply HEIGHT of FIRST CHILD and hide it again... .addClass('jsub-menu').css({ 'visibility': '', 'opacity': '', 'height': get_height_of_first_child + 'px', 'width': '0' }); j('.active').next('.jsub-menu').animate({ width: get_width }, 1000, function () { //Animate WIDTH j('.active').next('.jsub-menu').animate({ height: get_submenu_height }, 1000); //callback animate HEIGHT }); } //End if }, function () { j('.active').removeClass('active'); }); }); </code></pre> <p>I think that this is happening because my <b>Slide Up/Down</b> animations are conflicting with my <b>animate with/height</b> functions but I am not sure. I have tried to solve it by adding <code>stop()</code>,<code>stop(true,true)</code>,<code>stop(true,false)</code> in numerous combinations but failed. I am trying to solve this for days now so you stackers are my only hope. Please help! <br/>Thank you!!</p>
    singulars
    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