hide images and release the space.

hide images and release the space.

I have a lightbox gallery. Everything is fine but I wanted to make it filterable.
I used a tutorial and ended up with this code:


HTML:

  1. <ul id="filter">
        <li class="current"><a href="#">All</a></li>
        <li><a href="#">Kitchens</a></li>
        <li><a href="#">Bathrooms</a></li>
        <li><a href="#">CAD</a></li>
    </ul>

    <script>
    jQuery(function () {
      jQuery.thumbGrid.transitions.slideLeft = {in: {x:"0%", opacity:0}, out: {x:"-100%", opacity:0}};
      jQuery.thumbGrid.transitions.slideRight = {in: {x:"0%", opacity:0}, out: {x:"100%", opacity:0}};

      jQuery("[data-thumbgrid]").thumbGrid();
    });
    </script>

  2. <section class="content">
  3.   <div id="thumbGrid" class=""
  4.              data-thumbgrid="true"
  5.              data-effect="slideInverse"
  6.              data-delay="60"
  7.              data-timing="800"
  8.              data-pagination="6"
  9.              data-galleryeffectnext="slideLeft"
  10.              data-galleryeffectprev="slideRight"
  11.              data-cover="true">
  12.     <img src="img/LR/01.jpg" class="kitchens" alt="img04" data-highres="img/HR/01.jpg" data-captio\
  13. n="text1"/>
  14.     <img src="img/LR/02.jpg" class="kitchens" alt="img02" data-highres="img/HR/02.jpg" />
  15.     <img src="img/LR/03.jpg" class="bathrooms" alt="img01" data-highres="img/HR/03.jpg" data-capti\
  16. on="text2"/>
  17.     <img src="img/LR/04.jpg" class="cad" alt="img03" data-highres="img/HR/04.jpg" data-caption="text3"/>
  18.    </div>
  19. </section>

jquery:





  1. $(document).ready(function(){                                                                     
        $('#filter a').click(function() {                                                             
            $(this).css('outline','none');                                                            
            $('#filter li.current').removeClass('current');                                           
            $(this).parent().addClass('current');                                                     
                                                                                                      
            var filterVal = $(this).text().toLowerCase().replace(' ','-');                            
                                                                                                      
            if(filterVal == 'all') {                                                                  
                $('#thumbGrid img.hidden').fadeIn('slow').removeClass('hidden');                      
            } else {                                                                                  
                $('#thumbGrid img').each(function() {                                                 
                    if(!$(this).hasClass(filterVal)) {                                                
                        $(this).fadeOut('normal').addClass('hidden');                                 
                    } else {                                                                          
                        $(this).fadeIn('slow').removeClass('hidden');                                 
                    }                                                                                 
                });                                                                                   
            }                                                                                         
            return false;                                                                             
        });                                                                                           
    });       


Also tried hide():


  1. $(document).ready(function(){
  2.     $('#filter a').click(function() {
  3.         $(this).css('outline','none');
  4.         $('#filter li.current').removeClass('current');
  5.         $(this).parent().addClass('current');
  6.         var filterVal = $(this).text().toLowerCase().replace(' ','-');
  7.         if(filterVal == 'all') {
  8.             $('#thumbGrid img.hidden').removeClass('hidden').css('display', 'block');
  9.         } else {
  10.             $('#thumbGrid img').each(function() {
  11.                 if(!$(this).hasClass(filterVal)) {
  12.                     $(this).addClass('hidden').css('display', 'none');
  13.                 } else {
  14.                     $(this).removeClass('hidden').css('display', 'block');
  15.                 }
  16.             });
  17.         }
  18.         return false;
  19.     });
  20. });

In both cases, when I click on the categories they appear/disappear as intended. The only problem is that when an img gets hidden, there's still a gray container occupying the space. How can I free the space that a hidden img would normally occupy?


Thank you