【问题标题】:Sticky menu flickers/jumps at certain resolution粘性菜单以特定分辨率闪烁/跳跃
【发布时间】:2017-04-08 20:56:14
【问题描述】:

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

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

你知道为什么会这样吗?

我试图删除 Z-index,在标题 div 中设置溢出:自动和位置:未设置选项,但没有帮助。

【问题讨论】:

    标签: navigation sticky flicker


    【解决方案1】:

    找到它,在 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();
            });
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-23
      • 1970-01-01
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      相关资源
      最近更新 更多