Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery粘性顶部菜单栏请求_Javascript_Jquery - Fatal编程技术网

Javascript jQuery粘性顶部菜单栏请求

Javascript jQuery粘性顶部菜单栏请求,javascript,jquery,Javascript,Jquery,我正在寻找一个jQuery插件(或代码/指南),它可以: 这个不是免费的 注意:请注意,导航栏不是从一开始就放在顶部。一旦视口“点击”它,它就会粘住。你可以对@genesis link进行反向工程,这正是你正在寻找的脚本(不,这并不难) 我找不到非精简版本的url。。就是这样 (function ($) { $.fn.stickyMenubar = function (o) { o = $.extend({ top: null,

我正在寻找一个jQuery插件(或代码/指南),它可以:

这个不是免费的


注意:请注意,导航栏不是从一开始就放在顶部。一旦视口“点击”它,它就会粘住。

你可以对@genesis link进行反向工程,这正是你正在寻找的脚本(不,这并不难)

我找不到非精简版本的url。。就是这样

(function ($) {
    $.fn.stickyMenubar = function (o) {
        o = $.extend({
            top: null,
            floatingDiv: null,
            floatingDivBackground: false,
            megaMenu: true,
            onScroll: function () {},
            onLeaveTop: function () {},
            sensitivity: 7,
            padding: 5,
            container_width: 960
        }, o || {});
        var setLiActions = function (t, lvl) {
                var parent_ul = t.children('ul:first');
                if (lvl > 0) {
                    t.addClass('inner_menu').hide();
                } else {
                    if (!o.floatingDivBackground) {
                        t.addClass('smenubar_background');
                    }
                }
                t.mouseleave(function () {
                    $(this).children('li').children('ul').hide();
                });
                t.children('li').each(function () {
                    var li = $(this);
                    var class_parent = '';
                    var class_child = '';
                    var uls = li.children('ul');
                    if (uls.length) {
                        uls.each(function () {
                            setLiActions($(this), lvl + 1);
                        })
                        if (lvl == 0) {
                            li.children('a:first').addClass('arrow_down');
                        } else {
                            li.children('a:first').addClass('arrow_right');
                        }
                        if (!$.fn.hoverIntent) {
                            alert('hoverIntent javascript library must be included');
                            return;
                        }
                        var config = {
                            over: function () {
                                if (lvl == 0) {
                                    $(this).parent().children('li').not($(this)).children('ul').hide();
                                    var inner_ul = li.children('ul:first');
                                    var pos = li.position();
                                    var pos_ul = inner_ul.position();
                                    var top_c = pos.top + li.height();
                                    if (inner_ul.hasClass('show2left')) {
                                        var left_c = pos.left - inner_ul.width() + li.width() + (o.padding * 2);
                                        class_parent = 'inuseleft';
                                        class_child = 'inusechildleft';
                                        class_panel = 'left_slide';
                                        inner_ul.addClass('topleftradius')
                                    } else if (inner_ul.hasClass('mega_menu')) {
                                        var left_c = 0 + ($(document).width() / 2) - (o.container_width / 2);
                                        class_parent = 'inusemega', class_child = 'inusechildmega';
                                        class_panel = 'mega_slide';
                                        inner_ul.addClass('topleftradius').addClass('toprightradius');
                                    } else {
                                        var left_c = pos.left;
                                        class_parent = 'inuse';
                                        class_child = 'inusechild';
                                        class_panel = 'right_slide';
                                        inner_ul.addClass('toprightradius');
                                    }
                                    if (!$.browser.msie || ($.browser.msie && ($.browser.version > 7.0))) {
                                        if (inner_ul.width() <= (li.width() + (o.padding * 2))) {
                                            inner_ul.css('width', li.width() + (o.padding * 2));
                                            inner_ul.removeClass('topleftradius').removeClass('toprightradius');
                                        }
                                    }
                                    inner_ul.stop(true, true).css({
                                        top: top_c,
                                        left: left_c
                                    }).addClass(class_panel).slideDown(150);
                                    li.addClass(class_child);
                                } else {
                                    var inner_ul = li.children('ul');
                                    var pos = li.position();
                                    var pos_ul = inner_ul.position();
                                    var top_c = pos.top;
                                    if (inner_ul.hasClass('show2left')) {
                                        var left_c = pos.left - inner_ul.width() + li.width() - 1;
                                        class_parent = 'inuseleft';
                                        class_child = 'inusechildleft';
                                        class_panel = 'left_slide';
                                    } else {
                                        var left_c = pos.left + li.width();
                                        if ($.browser.mozilla) {
                                            left_c--;
                                        }
                                        class_parent = 'inuse';
                                        class_child = 'inusechild';
                                        class_panel = 'right_slide';
                                    }
                                    inner_ul.css({
                                        top: top_c,
                                        left: left_c
                                    }).addClass(class_panel).css({
                                        'white-space': 'nowrap'
                                    }).stop(true, true).animate({
                                        width: 'toggle'
                                    }, 300);
                                    li.addClass(class_child);
                                }
                            },
                            sensitivity: o.sensitivity,
                            timeout: 200,
                            out: function () {
                                li.stop(true, true).removeClass(class_child).children('ul').hide();
                            }
                        };
                        li.each(function () {
                            $(this).hoverIntent(config);
                            $(this).mouseleave(function () {
                                if (lvl == 0) {
                                    $(this).children('ul').hide();
                                }
                            });
                        });
                    } else {
                        li.mouseenter(function () {
                            li.stop(true, true).addClass(class_parent);
                        });
                        li.mouseleave(function () {
                            li.stop(true, true).removeClass(class_parent).children('ul').hide();
                        });
                    }
                });
            }
        return this.each(function () {
            var t = $(this);
            t.addClass('smenubar');
            if (!o.floatingDiv) {
                var floatingDiv = t;
            } else {
                var floatingDiv = o.floatingDiv;
                floatingDiv.css({
                    width: '100%'
                });
            }
            var top_Y = 0;
            if (!o.top) {
                top_Y = floatingDiv.position().top;
            } else {
                top_Y = o.top;
            }
            if (o.floatingDivBackground) {
                floatingDiv.addClass('smenubar_background');
                t.css({
                    'border-bottom': 'none'
                });
            }
            $(window).scroll(function () {
                if ($(this).scrollTop() >= top_Y) {
                    if (!($.browser.msie && ($.browser.version <= 7.0))) {
                        floatingDiv.addClass('float_top');
                        o.onLeaveTop.call(this);
                    }
                } else {
                    floatingDiv.removeClass('float_top').removeClass('float_top_ie7');
                    o.onScroll.call(this);
                }
                var open_menu = $('.inner_menu:visible');
                var parent_li = open_menu.parent();
                var pos = parent_li.position();
                open_menu.css({
                    top: pos.top + parent_li.height()
                });
            });
            t.find('.toggle_block').slideToggle();
            t.find('.toggle_handle').html('...').css('text-align', 'center');
            t.find('a').click(function () {
                if ($(this).hasClass('toggle_handle')) {
                    var prev = $(this).parent().prev('.toggle_block');
                    prev.slideToggle().prevUntil(':not(.toggle_block)').slideToggle();
                }
                if ($(this).attr('href') == '#') {
                    event.preventDefault();
                    return;
                }
            });
            if (o.megaMenu == true) {
                setLiActions(t, 0);
            }
        });
    };
})(jQuery);
(函数($){
$.fn.stickyMenubar=函数(o){
o=$.extend({
top:null,
floatingDiv:null,
floatingDivBackground:false,
megaMenu:没错,
onScroll:function(){},
onLeaveTop:函数(){},
敏感度:7,
填充:5,
货柜宽度:960
},o |{});
var setLiActions=功能(t,lvl){
var parent_ul=t.children('ul:first');
如果(lvl>0){
t、 addClass('内部菜单').hide();
}否则{
如果(!o.floatingDivBackground){
t、 addClass('smenubar_background');
}
}
t、 mouseleave(函数(){
$(this.children('li').children('ul').hide();
});
t、 子项('li')。每个(函数(){
var li=$(本);
var class_parent='';
var class_child='';
var uls=li.儿童(“ul”);
if(uls.长度){
uls.每个(功能(){
设定负债($(本),lvl+1);
})
如果(lvl==0){
li.children('a:first').addClass('arrow_down');
}否则{
li.children('a:first').addClass('arrow_right');
}
如果(!$.fn.hoverIntent){
警报(“必须包括hoverIntent javascript库”);
返回;
}
变量配置={
结束:函数(){
如果(lvl==0){
$(this).parent().children('li')。not($(this)).children('ul').hide();
var inner_ul=li.children('ul:first');
var pos=li.position();
var pos_ul=内部位置();
var top_c=位置top+高度();
if(内部_ul.hasClass('show2left')){
变量left_c=位置left-内部_ul.width()+li.width()+(o.padding*2);
class_parent='inuseleft';
class_child='inusechildleft';
类_面板='左_滑块';
内部添加类(“topleftradius”)
}else if(内部菜单类('mega_菜单')){
var left_c=0+($(document.width()/2)-(o.container_width/2);
父类='inusemega',子类='inusechildmega';
类_面板=‘巨型_幻灯片’;
内部添加类('topleftradius')。添加类('toprightradius');
}否则{
var left_c=位置左侧;
父类='inuse';
class_child='inusechild';
类_面板='右侧_幻灯片';
内部添加类(“toprightradius”);
}
如果(!$.browser.msie | |($.browser.msie&&($.browser.version>7.0))){
如果(内部宽度()=顶部宽度){
如果(!($.browser.msie&($.browser.version=top_Y){

如果(!($.browser.msie&($.browser.version您可以对@genesis link进行反向工程,这正是您要寻找的脚本(不,这并不难)

我找不到一个非精简版本的url。所以在这里

(function ($) {
    $.fn.stickyMenubar = function (o) {
        o = $.extend({
            top: null,
            floatingDiv: null,
            floatingDivBackground: false,
            megaMenu: true,
            onScroll: function () {},
            onLeaveTop: function () {},
            sensitivity: 7,
            padding: 5,
            container_width: 960
        }, o || {});
        var setLiActions = function (t, lvl) {
                var parent_ul = t.children('ul:first');
                if (lvl > 0) {
                    t.addClass('inner_menu').hide();
                } else {
                    if (!o.floatingDivBackground) {
                        t.addClass('smenubar_background');
                    }
                }
                t.mouseleave(function () {
                    $(this).children('li').children('ul').hide();
                });
                t.children('li').each(function () {
                    var li = $(this);
                    var class_parent = '';
                    var class_child = '';
                    var uls = li.children('ul');
                    if (uls.length) {
                        uls.each(function () {
                            setLiActions($(this), lvl + 1);
                        })
                        if (lvl == 0) {
                            li.children('a:first').addClass('arrow_down');
                        } else {
                            li.children('a:first').addClass('arrow_right');
                        }
                        if (!$.fn.hoverIntent) {
                            alert('hoverIntent javascript library must be included');
                            return;
                        }
                        var config = {
                            over: function () {
                                if (lvl == 0) {
                                    $(this).parent().children('li').not($(this)).children('ul').hide();
                                    var inner_ul = li.children('ul:first');
                                    var pos = li.position();
                                    var pos_ul = inner_ul.position();
                                    var top_c = pos.top + li.height();
                                    if (inner_ul.hasClass('show2left')) {
                                        var left_c = pos.left - inner_ul.width() + li.width() + (o.padding * 2);
                                        class_parent = 'inuseleft';
                                        class_child = 'inusechildleft';
                                        class_panel = 'left_slide';
                                        inner_ul.addClass('topleftradius')
                                    } else if (inner_ul.hasClass('mega_menu')) {
                                        var left_c = 0 + ($(document).width() / 2) - (o.container_width / 2);
                                        class_parent = 'inusemega', class_child = 'inusechildmega';
                                        class_panel = 'mega_slide';
                                        inner_ul.addClass('topleftradius').addClass('toprightradius');
                                    } else {
                                        var left_c = pos.left;
                                        class_parent = 'inuse';
                                        class_child = 'inusechild';
                                        class_panel = 'right_slide';
                                        inner_ul.addClass('toprightradius');
                                    }
                                    if (!$.browser.msie || ($.browser.msie && ($.browser.version > 7.0))) {
                                        if (inner_ul.width() <= (li.width() + (o.padding * 2))) {
                                            inner_ul.css('width', li.width() + (o.padding * 2));
                                            inner_ul.removeClass('topleftradius').removeClass('toprightradius');
                                        }
                                    }
                                    inner_ul.stop(true, true).css({
                                        top: top_c,
                                        left: left_c
                                    }).addClass(class_panel).slideDown(150);
                                    li.addClass(class_child);
                                } else {
                                    var inner_ul = li.children('ul');
                                    var pos = li.position();
                                    var pos_ul = inner_ul.position();
                                    var top_c = pos.top;
                                    if (inner_ul.hasClass('show2left')) {
                                        var left_c = pos.left - inner_ul.width() + li.width() - 1;
                                        class_parent = 'inuseleft';
                                        class_child = 'inusechildleft';
                                        class_panel = 'left_slide';
                                    } else {
                                        var left_c = pos.left + li.width();
                                        if ($.browser.mozilla) {
                                            left_c--;
                                        }
                                        class_parent = 'inuse';
                                        class_child = 'inusechild';
                                        class_panel = 'right_slide';
                                    }
                                    inner_ul.css({
                                        top: top_c,
                                        left: left_c
                                    }).addClass(class_panel).css({
                                        'white-space': 'nowrap'
                                    }).stop(true, true).animate({
                                        width: 'toggle'
                                    }, 300);
                                    li.addClass(class_child);
                                }
                            },
                            sensitivity: o.sensitivity,
                            timeout: 200,
                            out: function () {
                                li.stop(true, true).removeClass(class_child).children('ul').hide();
                            }
                        };
                        li.each(function () {
                            $(this).hoverIntent(config);
                            $(this).mouseleave(function () {
                                if (lvl == 0) {
                                    $(this).children('ul').hide();
                                }
                            });
                        });
                    } else {
                        li.mouseenter(function () {
                            li.stop(true, true).addClass(class_parent);
                        });
                        li.mouseleave(function () {
                            li.stop(true, true).removeClass(class_parent).children('ul').hide();
                        });
                    }
                });
            }
        return this.each(function () {
            var t = $(this);
            t.addClass('smenubar');
            if (!o.floatingDiv) {
                var floatingDiv = t;
            } else {
                var floatingDiv = o.floatingDiv;
                floatingDiv.css({
                    width: '100%'
                });
            }
            var top_Y = 0;
            if (!o.top) {
                top_Y = floatingDiv.position().top;
            } else {
                top_Y = o.top;
            }
            if (o.floatingDivBackground) {
                floatingDiv.addClass('smenubar_background');
                t.css({
                    'border-bottom': 'none'
                });
            }
            $(window).scroll(function () {
                if ($(this).scrollTop() >= top_Y) {
                    if (!($.browser.msie && ($.browser.version <= 7.0))) {
                        floatingDiv.addClass('float_top');
                        o.onLeaveTop.call(this);
                    }
                } else {
                    floatingDiv.removeClass('float_top').removeClass('float_top_ie7');
                    o.onScroll.call(this);
                }
                var open_menu = $('.inner_menu:visible');
                var parent_li = open_menu.parent();
                var pos = parent_li.position();
                open_menu.css({
                    top: pos.top + parent_li.height()
                });
            });
            t.find('.toggle_block').slideToggle();
            t.find('.toggle_handle').html('...').css('text-align', 'center');
            t.find('a').click(function () {
                if ($(this).hasClass('toggle_handle')) {
                    var prev = $(this).parent().prev('.toggle_block');
                    prev.slideToggle().prevUntil(':not(.toggle_block)').slideToggle();
                }
                if ($(this).attr('href') == '#') {
                    event.preventDefault();
                    return;
                }
            });
            if (o.megaMenu == true) {
                setLiActions(t, 0);
            }
        });
    };
})(jQuery);
(函数($){
$.fn.stickyMenubar=函数(o){
o=$.extend({
top:null,
floatingDiv:null,
floatingDivBackground:false,
megaMenu:没错,
onScroll:function(){},
onLeaveTop:函数(){},
敏感度:7,
填充:5,
货柜宽度:960
},o |{});
var setLiActions=功能(t,lvl){
var parent_ul=t.children('ul:first');
如果(lvl>0){
t、 addClass('内部菜单').hide();
}否则{
如果(!o.floatingDivBackground){
t、 addClass('smenubar_background');
}
}
t、 mouseleave(函数(){
$(this.children('li').children('ul').hide();
});
t、 子项('li')。每个(函数(){
var li=$(本);
var class_parent='';
var class_child='';
var uls=li.儿童(“ul”);
if(uls.长度){
uls.每个(功能(){
设定负债($(本),lvl+1);
})
如果(lvl==0){
li.children('a:first').addClass('arrow_down');
}否则{