Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:22:27+00:00 2026-05-27T20:22:27+00:00

I have an issue with a toggling animation with JQuery. I have a menu,

  • 0

I have an issue with a toggling animation with JQuery. I have a menu, which has subitems, which slide open on hover of the main item. This I can achieve fine, however, for a long list of items, I would prefer to be able to stop the opening, and slide shut the menu, without having to wait for the slideDown() animation to complete.

$('.menubar-topitem').on('mouseenter',function(){
    $(this).children('.menubar-inner').stop(true).slideDown(); 
}).on('mouseleave',function(){
    $(this).children('.menubar-inner').stop(true).slideUp();
});

This code achieves what I require, however when I then hover back over the menu item, the submenu only opens as far as the animation reached before I stopped it the first time. It seems that JQuery stores the height of the submenu from when the animation was stopped first time, and then only opens as far as this the second time.

I am aware that I can fix this problem by using stop(true,true) but that creates a horrible jump in the animation. Is there anyway I can prevent this behaviour without having to complete the animation, or any work around so that the user does not see any jumps, but instead sees a flowing menu system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:22:28+00:00Added an answer on May 27, 2026 at 8:22 pm

    The fix for this is to explicitly animate hard-coded values rather than depending on the slideUp/slideDown functions:

    $('.menubar-topitem').on('mouseenter',function(){
        var $this  = $(this),
            height = $this.children('.menubar-inner').children().height();
        $this.children('.menubar-inner').stop().animate({height : height}, 250); 
    }).on('mouseleave',function(){
        $(this).children('.menubar-inner').stop().animate({height : 0}, 250);
    });
    

    Then set the CSS overflow property to hidden for the animated elements. Also to dynamically get the height of the .menubar-inner elements you can nest a div in them and get the height of that div element:

    HTML–

    <div class="menubar-topitem">
        <h1>This is a Menu Top Item</h1>
        <div class="menubar-inner">
            <div>
                <p>Some Content</p>
                <p>Some More Content</p>
            </div>
        </div>
    </div>
    

    CSS–

    .menubar-inner {
        overflow : hidden;
        height   : 0;
    }
    

    Here is a demo: http://jsfiddle.net/n6h2S/

    You will run into the same problem with fadeIn/fadeOut but there is another function called fadeTo that allows you to explicitly set the opacity to fade to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of an issue with a toggle visibility function which operates
I have a JTable using a custom DefaultTableModel which has some Booleans in the
Im writing sql query and i have issue which i cannot fix. I'm trying
i have done drag and drop using with jquery. here i have issue that
I have issue where i want to create Dynamic function which will do some
I have issue with url rewrite. I have a site example.com that has a
I have a java swing application which has a form that I populate by
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We are new to ROR, We have issue in creating Login/Logout process in ROR
Share your ideas please! I have issue to check the folder and convert a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.