Loading...
 
Skip to main content

History: Sticky Topbar

Source of version: 1

Copy to clipboard
            {CODE(caption=>YAML,wrap=>0)}
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);
{CODE}
        

History

Information Version
Tue 25 of Feb, 2020 11:07 GMT-0000 Jonny Bradley add a warning 2
Thu 24 of Mar, 2016 19:47 GMT-0000 Jean-Marc Libs Share with community 1