From c2a62aad1735a2b8e08e37a02f4414c0d7bb0d6c Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 31 Aug 2021 18:01:12 +0800 Subject: [PATCH] fix menu --- assets/javascripts/app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index ba3854b..39dc725 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -9,8 +9,11 @@ if ( $('.header-banner').length != 0) { $('.layout-header').css('height', ''); var scrollTop = $(window).scrollTop(); - var scrollBottom = $('html').height() - $(window).height() - $('.kenjohn').height()*2; - if (scrollTop>50 && scrollBottom>0) { /* 要滑動到選單的距離 */ + var scrollBottom = $('html').height() - $(window).height() - $('.kenjohn').height(); + if (scrollTop>5 && scrollBottom>0) { /* 要滑動到選單的距離 */ + if (parseInt($('.layout-content').css('margin-top'))==0){ + $('.layout-content').css('margin-top',$('.kenjohn').height()); + } $('.kenjohn').addClass('navFixed').removeClass('navRel'); /* 幫選單加上固定效果 */ } else { if ($('.header-banner').html().trim() == "") { @@ -18,6 +21,7 @@ }else{ $('.kenjohn').removeClass('navRel').removeClass('navFixed'); /* 移除選單固定效果 */ } + $('.layout-content').css('margin-top',''); } } }