码云 顶部导航及底栏效果源码

本文探讨了为何大部分程序员难以成为架构师的原因,分析了所需技能及经验的重要性。
  (function() {
    var updateNavbar;
  
    updateNavbar = function() {
      if (window.scrollY > 5) {
        return $('#git-header-nav').addClass('floating');
      } else {
        return $('#git-header-nav').removeClass('floating');
      }
    };
  
    updateNavbar();
  
    $(window).on('scroll', updateNavbar);
  
  }).call(this);
  (function () {
    // 更新底栏的位置,当页面内容高度小于窗口高度时,会将底栏浮动定位在窗口底端
    function updateFooterPosition() {
      var pageHeight = document.body.offsetHeight;
      if ($footer.hasClass('fixed-bottom')) {
        pageHeight += $footer.outerHeight();
        if (pageHeight > $(window).height()) {
          $footer.removeClass('fixed-bottom');
        }
      } else {
        if (pageHeight < $(window).height()) {
          $footer.addClass('fixed-bottom');
        }
      }
    }
    var $footer = $('#git-footer-main');
    $(document).on('ready', updateFooterPosition);
    $(window).on({
      'scroll': updateFooterPosition,
      'resize': updateFooterPosition
    });
    // 每隔一段时间检测页面高度变化,确保底栏能在页面最底端
    setInterval(updateFooterPosition, 500);
  })();

转载于:https://my.oschina.net/janfon/blog/1518481

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值