Team:Groningen/Template/SCRIPTS/scrollmenu

From 2014.igem.org

(Difference between revisions)
Line 2: Line 2:
$(document).ready(function () {
$(document).ready(function () {
   var menuIconsHeight = $('.default .module.menu .item .icon').height();
   var menuIconsHeight = $('.default .module.menu .item .icon').height();
 +
  var newMenuHeight = 0;
   $(window).scroll(function(){
   $(window).scroll(function(){
       if( $(window).scrollTop() > menuIconsHeight) {
       if( $(window).scrollTop() > menuIconsHeight) {
-
         $('.default .module.menu .content').css({position: 'fixed', top: '-100pt'});
+
        // 17 is height of topbar
 +
        newMenuHeight = $(document).scrollTop()-menuIconsHeight-17;
 +
         $('.default .module.menu .content').css({position: 'absolute'});
 +
        $('.default .module.menu .content').css('top', newMenuHeight);
 +
 
       } else {
       } else {
         $('.default .module.menu .content').css({position: 'relative', top: '0px'});
         $('.default .module.menu .content').css({position: 'relative', top: '0px'});

Revision as of 12:21, 17 October 2014

$(document).ready(function () { var menuIconsHeight = $('.default .module.menu .item .icon').height(); var newMenuHeight = 0; $(window).scroll(function(){ if( $(window).scrollTop() > menuIconsHeight) { // 17 is height of topbar newMenuHeight = $(document).scrollTop()-menuIconsHeight-17; $('.default .module.menu .content').css({position: 'absolute'}); $('.default .module.menu .content').css('top', newMenuHeight); } else { $('.default .module.menu .content').css({position: 'relative', top: '0px'}); } }) });