Q:

How to prevent empty space when fading in/out div to avoid momentary site collapse

I am using a script to allow the user to alternate between view modes (Grid, List, and Full). When the user changes view modes, the active view fades out and the selected fades in. During that transition, there is empty space and as my site is responsive I do not want to set a fixed max-height to the content.
As you can see from the following, the footer jumps up when you switch view modes..
http://fiddle.jshell.net/9ae3T/12/
Does anyone now a method to set a new max-height for the content each time the view mode is set? (Thereby avoiding the momentary negative space and adjusting to the height of the active content?)
HTML:
 <ul class="tabs js-view-mode">
      <li><a href="#list">List</a></li>
      <li><a href="#grid">Grid</a></li>
      <li><a href="#full">Full</a></li>
    </ul>

    <section id="viewMode" class="content">
      <div id="list">here is list mode content</div>
      <div id="grid">here is grid mode content</div>
      <div id="full">here is full mode content</div>
    </section>

<footer></footer>

JQUERY:
$(document).ready(function(){
  var wrap = $('#viewMode'),
      viewMode = $.cookie( 'view-mode' );
  wrap.children().hide();

  $('.js-view-mode').on( 'click', 'a',function( e ){
    e.preventDefault();
    var t = $(this),
        type = t.attr('href');

   wrap.children().fadeOut(); $(type).delay(500).fadeIn();

    viewMode = $.cookie( 'view-mode', type );

  });

  if ( viewMode ) {
    $('.js-view-mode a[href='+ viewMode +']').trigger('click');
  } else {
    $('.js-view-mode li:first a').trigger( 'click' );
  }

});

CSS (for demonstrative purposes):
footer {background: red; display: block; width: 100%; height: 5px}

#list {height: 20px; width: 100%;display: block}
#grid {height: 55px; width: 100%;display: block}
#full {height: 100px; width: 100%;display: block}

/*.content {THIS NEEDS TO BE SET TO THE ACTIVE VIEWMODE CONTENT HEIGHT} */

A:

Here a working exemple   http://fiddle.jshell.net/9ae3T/17/
the modif is : 
 var lheight = $("#viewMode").height();
      if(lheight != 0){
   $("#viewMode").css("height",lheight+"px");         
      }
      wrap.children().fadeOut(); $(type).delay(500).fadeIn(function(){
          $("#viewMode").css("height","auto");
      });

I have taken the height of the div (you can get rid of the poor != 0 test, it's only to prevent the modification for the first display). Before changing the kind of view, I force the height of the div. In the fadeIn callback, I set the div's height to auto...

