This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Make Sub Menus Slide Down Gently

Open 15 replies premiumthemetheme-vantage
10 years ago · Last reply by Andrew Misplon 10 years ago

Hi Greg & gang,
I am wondering what css code to use to make the sub menu items under the main nav items roll down gently as shown in this tutorial: http://candpgeneration.com/toys/CSS3-dropdown-tut.php
I know it’s the transition property and I have played around a bit, but I can’t seem to make it happen.
Thanks in advance!

URL: http://www.barbpetersonwebdesign.com/art

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

15
  1. Andrew Misplon Staff 10 years, 3 months ago

    Hi Barb

    The menu is controlled by JavaScript, not CSS. However, you can install a plugin called Header and Footer Scripts, I’m using the one by WPBeginner. Then, in the header field provided by the plugin, insert:

    <script>
    jQuery(function($){
        // The menu hover effects
        $('#masthead')
            .on('mouseenter', '.main-navigation ul li', function(){
                var $$ = $(this);
                var $ul = $$.find('> ul');
                $ul.css({
                    'display' : 'block',
                    'opacity' : 0
                }).clearQueue().animate({opacity: 1}, 900);
                $ul.data('final-opacity', 1);
            } )
            .on('mouseleave', '.main-navigation ul li', function(){
                var $$ = $(this);
                var $ul = $$.find('> ul');
                $ul.clearQueue().animate( {opacity: 0}, 900, function(){
                    if($ul.data('final-opacity') === 0) {
                        $ul.css('display', 'none');
                    }
                });
                $ul.data('final-opacity', 0);
            } );
    });
    </script>

    See my two 900 values. Those are 250 by default. You can adjust to slow the transition down further. You can reduce to speed it up.

  2. Barb Peterson 10 years, 3 months ago

    Thanks for the code, Andrew, and for taking the time to research a rather esoteric request!
    However, it must be conflicting with some of the existing code in the Vantage’s menu javascript. Take a look at how things roll out now that I’ve added your script (www.barbpetersonwebdesign/art). I tried adjusting the 900 upward and downward, but it never achieved the smooth rolldown as in the tutorial I referenced above.

    Not the end of the world if this can’t be achieved but it is a really nice smooth effect and adds a calmness to the navigation process…
    Thanks in advance,
    ~Barb

  3. Andrew Misplon Staff 10 years, 3 months ago

    I can take a quick look if you’d like.

  4. Andrew Misplon Staff 10 years, 3 months ago

    Hi Barb

    Would it be possible for you to create a temporary admin account for us so we can log in and take a look? You can create the account with the following email address:

    [email protected]

    Just navigate to Users > Add New in your WordPress admin. Enter siteorigin for the username and [email protected] for the email address. Make sure you’ve selected Administrator for the role and enabled the “Send Password” field so we receive the details.

    Once we’re finished taking a look, you can delete this account. We’ll let you know when to do that.

  5. Barb Peterson 10 years, 3 months ago

    Thanks, Andrew!

    The password should be arriving in your inbox any moment! Your help is much appreciated!!!

  6. Andrew Misplon Staff 10 years, 3 months ago

    Hi Barb

    Sorry, doesn’t seem like it arrived. Please, could you send using the Private Reply option bottom right. Thanks :)

  7. Barb Peterson Private 10 years, 3 months ago

    This is a private message.

  8. Andrew Misplon Staff 10 years, 3 months ago

    I can see the problem, the transition is happening twice, the second transition is the delayed one. I can’t figure out why I’m not getting the same result on my local demo.

  9. Andrew Misplon Staff 10 years, 3 months ago

    Fixed :) Check now.

  10. Andrew Misplon Staff 10 years, 3 months ago

    The problem was Appearance > Theme Settings > General > Enqueue JavaScript in Footer. For this application we that setting disabled. We need the scripts in the default location, in the document head.

  11. Barb Peterson 10 years, 3 months ago

    Andrew! You’re a magician! Thanks so much for figuring this out!

    Do you think it makes an appreciable site performance difference with all of the JavaScript NOT being enqueued in the the footer?

    In other words, now that you have spent all that time helping me with this (and I truly appreciate the time spent), is the effect worth any decrement in site speed?

  12. Andrew Misplon Staff 10 years, 3 months ago

    There will be a small difference. On normal DSL connections it probably isn’t noticeable. Up to you.

  13. Barb Peterson 10 years, 3 months ago

    Thanks again for your prompt help!

  14. Andrew Misplon Staff 10 years, 3 months ago

    For sure :)

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread