Loading...
 

Sticky Topbar

YAML
preferences: 
 header_custom_js: |
  (function(window,undefined){
  // Duplicate topbar, rename to topbar-clone, re-inject somewhere in the page
  $('#topbar').clone()
  .attr("id","topbar-clone")
  .insertAfter('#topbar');
  // Place on top of page but hidden at first
  $('#topbar-clone').css({
  position: 'fixed',
  top: '0px',
  width: 'inherit',
  display: 'none',
  'z-index': 3
  });
  // Get and store default display style for topbar
  $topbar_display = $('#topbar').css('display');
  $(window).on("scroll", function () {
  if ($(window).scrollTop() > $('#topbar').offset().top) {
  // If topbar scrolls out of the visible page, display topbar-clone
  $('#topbar-clone').css('display', $topbar_display).css('width',$('#topbar').width());
  } else {
  // If topbar is visible, hide topbar-clone
  $('#topbar-clone').css('display','none');
  }
  });
  })(window);

Category: release
Category: 15.x
Category: 16.x