Javascript 在megamenu hoverout wordpress上添加延迟

Javascript 在megamenu hoverout wordpress上添加延迟,javascript,wordpress,delay,hoverintent,megamenu,Javascript,Wordpress,Delay,Hoverintent,Megamenu,当我从菜单中取出鼠标指针的那一刻,它就消失了,我觉得很烦人。我想或者只是稍微延迟一下,这样当我不小心滑出菜单时,菜单会更宽容一些,或者使用hoverIntent。问题是,无论我在谷歌上搜索了多少,我都找不到任何地方有一本我能理解的指南。说到javascripting,我是一个真正的新手。:) 我在scripts.js中找到了这个,我认为是控制菜单悬停属性的编程: // STARTS MEGA MENU var temp, menu = jQuery("#navigation .menu"); m

当我从菜单中取出鼠标指针的那一刻,它就消失了,我觉得很烦人。我想或者只是稍微延迟一下,这样当我不小心滑出菜单时,菜单会更宽容一些,或者使用hoverIntent。问题是,无论我在谷歌上搜索了多少,我都找不到任何地方有一本我能理解的指南。说到javascripting,我是一个真正的新手。:)

我在scripts.js中找到了这个,我认为是控制菜单悬停属性的编程:

// STARTS MEGA MENU
var temp, menu = jQuery("#navigation .menu");
menu.find("li").hover(function(){
    jQuery(this).children('.children').hide().slideDown('normal');
    if(jQuery(this).hasClass('mega-item'))
        jQuery(this).children('.children').find('.children').hide().slideDown('normal');
    try{
        $tmp=(jQuery(this).children('.children').offset().left+jQuery(this).children('.children').width())-(jQuery("#header .twelve").offset().left+jQuery("#header .twelve").width());
        if($tmp>0){
            jQuery(this).children('.children').css("right","0");
        }
    }
    catch(e){}
},function(){
    jQuery(this).children('.children').stop(true,true).hide();
}); 

menu.children("li").each(function(){
    temp = jQuery(this);
    if(temp.children().hasClass("children"))
        temp.addClass("showdropdown");

    if(temp.hasClass('rel'))
        temp.find('.children').append('<span class="mg-menu-tip" style="width:'+temp.width()+'px"></span>');
    else
        temp.find('.children').append('<span class="mg-menu-tip" style="left:'+(temp.position().left-20)+'px;width:'+temp.width()+'px"></span>');
});


menu.find(".children.columns").each(function(){
    $countItems=1;
    jQuery(this).children(".mega-item").each(function(){
        temp = jQuery(this);
        if(temp.hasClass("clearleft")){
            $countItems=4;
        }else if(($countItems%3)==1 && $countItems!=1){
            temp.addClass("clearleft");
        }
        $countItems++;
    });
});
$i = 0;
menu.find(">li>ul.children").each(function(){
    jQuery(this).find('>li>ul.children').parent().find('>a>span').addClass('menu-span-arrow').html('â–º');
});
menu.find("ul.children>li").hover(function(){
    jQuery(this).children("ul.children").css('left', (jQuery(this).width()-5)+"px");       
});
// END MEGA MENU
稍晚一点,我就被
wp_排队_脚本('hoverIntent2')

所以我请我的朋友帮我,大约一个小时后,我们就这样结束了(我很高兴:):

//启动超级菜单
var temp,menu=jQuery(#navigation.menu”);
变量菜单_show=false;
变量菜单超时;
var菜单对象;
menu.find(“li”).not(“.mega item”).hover(函数(){
jQuery(this).children('.children').hide().slideDown('normal');
if(jQuery(this).hasClass('mega-item'))
jQuery(this).children('.children').find('.children').hide().slideDown('normal');
试一试{
$tmp=(jQuery(this).children('.children').offset().left+jQuery(this).children('.children').width())-(jQuery('.header.seven').offset().left+jQuery('.header.seven').width());
如果($tmp>0){
jQuery(this).children('.children').css(“右”,“0”);
}
}
捕获(e){}
},函数(){
jQuery(this).children('.children').stop(true,true.hide();
}); 
jQuery('#menu-item-2462')。悬停(函数(){
clearTimeout(菜单超时);
menu_object=jQuery(this).children('.children');
如果(!菜单显示){
菜单显示=真;
jQuery(this).children('.children').hide().show();
if(jQuery(this).hasClass('mega-item'))
jQuery(this).children('.children').find('.children').hide().show();
试一试{
$tmp=(jQuery(this).children('.children').offset().left+jQuery(this).children('.children').width())-(jQuery('.header.seven').offset().left+jQuery('.header.seven').width());
如果($tmp>0){
jQuery(this).children('.children').css(“右”,“0”);
}
}捕获(e){}
}
},函数(){
menu_timeout=setTimeout(function(){menu_object.stop(true,true).hide();menu_show=false;},500);
}); 
菜单。子菜单(“li”)。每个(函数(){
temp=jQuery(这个);
if(temp.children().hasClass(“children”))
临时添加类(“显示下拉列表”);
if(临时hasClass('rel'))
临时查找('.children').append('');
其他的
临时查找('.children').append('');
});
menu.find(“.children.columns”).each(function(){
$countItems=1;
jQuery(this).children(“.megaitem”).each(function(){
temp=jQuery(这个);
if(临时hasClass(“clearleft”)){
$countItems=4;
}如果(($countItems%3)==1&&$countItems!=1),则为else{
临时添加类(“clearleft”);
}
$countItems++;
});
});
$i=0;
menu.find(“>li>ul.children”)。每个(函数(){
jQuery(this).find('>li>ul.children').parent().find('>a>span').addClass('menu-span-arrow').html('►');
});
menu.find(“ul.children>li”).hover(函数(){
jQuery(this).children(“ul.children”).css('left',(jQuery(this).width()-5)+“px”);
});
//结束大菜单

我希望这有助于某人!致以最良好的祝愿:)

我仍然每天查看这篇帖子,希望有人能帮助我:)
wp_register_script('hoverIntent2', get_template_directory_uri() . '/js/jquery.hoverIntent.js');
// STARTS MEGA MENU
var temp, menu = jQuery("#navigation .menu");
var menu_show = false;
var menu_timeout;
var menu_object;

menu.find("li").not('.mega-item').hover(function(){
    jQuery(this).children('.children').hide().slideDown('normal');
    if(jQuery(this).hasClass('mega-item'))
        jQuery(this).children('.children').find('.children').hide().slideDown('normal');
    try{
        $tmp=(jQuery(this).children('.children').offset().left+jQuery(this).children('.children').width())-(jQuery("#header .twelve").offset().left+jQuery("#header .twelve").width());
        if($tmp>0){
            jQuery(this).children('.children').css("right","0");
        }
    }
    catch(e){}
},function(){
    jQuery(this).children('.children').stop(true,true).hide();
}); 

jQuery('#menu-item-2462').hover(function(){

    clearTimeout(menu_timeout);

    menu_object = jQuery(this).children('.children');

    if(!menu_show) {
        menu_show = true;

        jQuery(this).children('.children').hide().show();
        if(jQuery(this).hasClass('mega-item'))
            jQuery(this).children('.children').find('.children').hide().show();
        try{
            $tmp=(jQuery(this).children('.children').offset().left+jQuery(this).children('.children').width())-(jQuery("#header .twelve").offset().left+jQuery("#header .twelve").width());
            if($tmp>0){
                jQuery(this).children('.children').css("right","0");
            }
        } catch (e) {}
    }
},function(){

    menu_timeout    = setTimeout(function() { menu_object.stop(true,true).hide(); menu_show = false;} , 500);



}); 



menu.children("li").each(function(){
    temp = jQuery(this);
    if(temp.children().hasClass("children"))
        temp.addClass("showdropdown");

    if(temp.hasClass('rel'))
        temp.find('.children').append('<span class="mg-menu-tip" style="width:'+temp.width()+'px"></span>');
    else
        temp.find('.children').append('<span class="mg-menu-tip" style="left:'+(temp.position().left-20)+'px;width:'+temp.width()+'px"></span>');
});


menu.find(".children.columns").each(function(){
    $countItems=1;
    jQuery(this).children(".mega-item").each(function(){
        temp = jQuery(this);
        if(temp.hasClass("clearleft")){
            $countItems=4;
        }else if(($countItems%3)==1 && $countItems!=1){
            temp.addClass("clearleft");
        }
        $countItems++;
    });
});
$i = 0;
menu.find(">li>ul.children").each(function(){
    jQuery(this).find('>li>ul.children').parent().find('>a>span').addClass('menu-span-arrow').html('►');
});
menu.find("ul.children>li").hover(function(){
    jQuery(this).children("ul.children").css('left', (jQuery(this).width()-5)+"px");       
});
// END MEGA MENU