Theme Support Forum

Support Forum for Free and Premium Themes. Premium Theme Forums are Private! Please log in first to see the Premium forums

If you Like the Asteria Lite Theme and want to Keep it free forever Please Rate it on Wordpress.org (It only takes a few seconds)
Viewing 2 posts - 1 through 2 (of 2 total)

jQuery bug with menu color animation

Home Forums Free Theme Support Asteria Lite jQuery bug with menu color animation

  • #86408

    Mickey

    Hi there,

    Just wanted to let you know about a jQuery bug in the following code in asteria.js:

    //MENU Animation
    	if (jQuery(window).width() > 768) {
    	jQuery('#topmenu ul > li').hoverIntent(function(){
    	jQuery(this).find('.sub-menu:first, ul.children:first').slideDown({ duration: 200});
    		jQuery(this).find('a').not('.sub-menu a').stop().animate({"color":primarycolor}, 200);
    	}, function(){
    	jQuery(this).find('.sub-menu:first, ul.children:first').slideUp({ duration: 200});	
    		jQuery(this).find('a').not('.sub-menu a').stop().animate({"color":menutext}, 200);
    	
    	});

    We noticed our sub-menus were changing colors in odd ways, and a bit of digging led us to the issue here. As you can see, the initial jQuery selectors target two classes:

    find('.sub-menu:first, ul.children:first')

    which is good since the .sub-menu class doesn’t actually exist in the markup. The following .not() selectors however are missing the ul.children selector:

    not('.sub-menu a')

    Which means that sub-menu items ARE changing color when they should not be. Replacing the entire code block with the following fixes the problem:

    //MENU Animation
    	if (jQuery(window).width() > 768) {
    	jQuery('#topmenu ul > li').hoverIntent(function(){
    	jQuery(this).find('.sub-menu:first, ul.children:first').slideDown({ duration: 200});
    		jQuery(this).find('a').not('.sub-menu a, ul.children a').stop().animate({"color":primarycolor}, 200);
    	}, function(){
    	jQuery(this).find('.sub-menu:first, ul.children:first').slideUp({ duration: 200});	
    		jQuery(this).find('a').not('.sub-menu a, ul.children a').stop().animate({"color":menutext}, 200);
    	
    	});
    #86489

    Towfiq I.

    administrator

    Thanks for the input Mickey, the ul.children class is added when you did not setup a menu from Appearance> Menus, when you do, the class is not being added by wordpress. I assumed everyone would use the wordpress custom menu instead of the automatic one that appears by default. but I think there should be a backup. will add this to the next version. Thanks 🙂

You must be logged in to reply to this topic.