粘滞式菜单以特定分辨率闪烁/跳跃

时间:2017-04-08 20:56:15

标签: navigation sticky flicker

这是主题:http://keenthemes.com/free-bootstrap-templates/onepage-1-bootstrap-themefreebie-onepage-1-frontend-theme/

调整大小时,宽度为1024-1040px,菜单开始跳跃并闪烁。

为什么会发生这种情况?

我试图删除Z-index,设置overflow:auto和position:未设置标题div中的选项,没有帮助。

1 个答案:

答案 0 :(得分:0)

在layouts.js中找到它,这个代码的和平正在给出问题:

 var handleHeaderPosition = function () {
        var CurrentHeaderPosition = $(".header").offset().top;// current header's vertical position

        var headerFix = function(){
            var CurrentWindowPosition = $(window).scrollTop();// current vertical position
            if (CurrentWindowPosition > CurrentHeaderPosition) {
                $(".header").addClass("fixNav");
            } else {
                $(".header").removeClass("fixNav");
            }
        };

        headerFix();// call headerFix() when the page was loaded
        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
            $(window).bind("touchend touchcancel touchleave", function(e){
                headerFix();
            });
        } else {
            $(window).scroll(function() {
                headerFix();
            });
        }
    }

    var handleGo2Top = function () {       
        var Go2TopOperation = function(){
            var CurrentWindowPosition = $(window).scrollTop();// current vertical position
            if (CurrentWindowPosition > 300) {
                $(".go2top").show();
            } else {
                $(".go2top").hide();
            }
        };

        Go2TopOperation();// call headerFix() when the page was loaded
        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
            $(window).bind("touchend touchcancel touchleave", function(e){
                Go2TopOperation();
            });
        } else {
            $(window).scroll(function() {
                Go2TopOperation();
            });
        }
    }

  var handleMobiToggler = function () {
        $(".mobi-toggler").on("click", function(event) {
            event.preventDefault();//the default action of the event will not be triggered

            $(".header").toggleClass("menuOpened");
            $(".header").find(".header-navigation").toggle(300);            
        });

        function SlideUpMenu () {
            $(".header-navigation a").on("click", function(event) {
                if ($(window).width()<1024) {  
                    event.preventDefault();//the default action of the event will not be triggered
                    $(".header-navigation").slideUp(100); // by changing 100 to 0 helps the issue, havent found any drawbacks yet
                    $(".header").removeClass("menuOpened");
                }
            });
            $(window).scroll(function() {
                if (($(window).width()>480)&&($(window).width()<1024)) {  
                    $(".header-navigation").slideUp(100); // by changing 100 to 0 helps the issue, havent found any drawbacks yet
                    $(".header").removeClass("menuOpened");
                }
            });
        }
        SlideUpMenu();
        $(window).resize(function() {
            SlideUpMenu();
        });
    }