Jquery animate a three levels menu

2019-06-08 16:37发布

I'm building a menu compose of three levels with hover animations.

Here is a JSFIDLE of my menu

My goals:

1 - When the user is hovering the main top menu, I would like to animate the second level and fadein all links content. When the user is leaving the header section. I would like to fadeout links content and top slide the second menu level. Note: I would like to remove the queue effect.

2 - When the second level is visible (links), if the user is clicking on the about/contact section I'm sliding the third menu level with the correct content. Note: the second menu level has to stay visible. If the user is clicking on the close button, I'm closing the third level

3 - At any moment, if the user is leaving the header area, first I need to fade out all text, and then, slide-top the second and third menu.

Any help would be very appreciated =) Thanks

HTML:

<header>
    <div id="main-header">
        <div class="left"><img src="http://design-online-logo.com/wp-content/uploads/2013/10/Deutsch-Logo.png"></div>
        <div class="middle"><a href=""><img src="http://design-online-logo.com/wp-content/uploads/2013/10/Deutsch-Logo.png"></a></div>
        <a id="tray-button"><div class="right"></div></a>
    </div><!-- main-header -->
    <div id="slidding-header-menu">
        <div id="relative-container">
            <ul id="galleries">
                <li><a>sunshine</a></li><li><a>ok</a></li><li><a>test</a></li>              
            </ul><!-- galleries -->
            <ul id="pages">
                <li id="about"><p>ABOUT</p></li>
                <li id="contact"><p>CONTACT</p></li>
                <li><img src="http://localhost/ashvasali/wp-content/themes/ashvasali/assets/img/ash/Ash-Vesali-close.png"></li>
            </ul><!-- pages -->
        </div><!-- relative-container -->
    </div><!-- slidding-header-menu -->
    <div id="slidding-about-contact-content">
        <div id="relative-container-about-contact">
            <div id="about-content">
                <p>"ABOUT CONTENT</p>
            </div>      
            <div id="contact-content">
                <p id="tel">CONTACT</p> 
                <p id="email">CONTENT</p>       
                <div id="logo-container">
                    <div id="tumblr"></div>
                    <div id="instagram"></div>
                    <div id="twitter"></div>
                </div><!-- logo-container -->
            </div>
        </div><!-- relative-container-about-contact -->
    </div><!-- slidding-about-contact-content -->
</header>

My JS:

        jQuery("header").hover(function() {
            jQuery("#slidding-header-menu").slideToggle();
                jQuery("#about").click(function() {
                    jQuery("#slidding-about-contact-content").slideToggle();
                });
        });

1条回答
Root(大扎)
2楼-- · 2019-06-08 17:00

Just to give you an idea: http://jsfiddle.net/S9Gpa/12/, I guess you will manage it by yourself to fadeOut the link texts. By the way: hover is deprecated.

jQuery("header").mouseenter(function () {
    jQuery("#slidding-header-menu").finish().slideDown();
}).mouseleave(function () {
    jQuery("#slidding-header-menu").finish().slideUp();
    jQuery("#slidding-about-contact-content").finish().slideUp();
});

jQuery("#about").click(function () {
    jQuery("#slidding-about-contact-content").slideToggle();
});
查看更多
登录 后发表回答