masonry icon indicating copy to clipboard operation
masonry copied to clipboard

Default filter (not an issue just a question :) )

Open b3nhartl3y opened this issue 15 years ago • 2 comments

Hi Desandro,

Bet your getting sick of me now. Just wondered what the best way is to set up a default filter - instead of initially seeing all 'bricks' could it show "red" only when page is first loaded and hide "blue" and "green".

Hope that makes sense.

Kind regards,

Ben

b3nhartl3y avatar Feb 04 '11 18:02 b3nhartl3y

Filtering is going to be unsupported in Masonry once Isotope is released next week. Here's how you would set up a default filter with Isotope:

$('#container').isotope({
  filter: '.red'
});

And on subsequent filters, the syntax is the same.

$('#container').isotope({
  filter: '.blue'
});

desandro avatar Feb 04 '11 19:02 desandro

I am sorry but I can get the answer and I have the same question. Where do I have to place the above code in this:

  $('#filtering-nav a').click(function(){
    var colorClass = '.' + $(this).attr('class');
    if(colorClass=='.all') {
      // show all hidden boxes
      $wall.children('.invis')
        .toggleClass('invis').fadeIn(speed);
    } else {  
      // hide visible boxes 
      $wall.children().not(colorClass).not('.invis')
        .toggleClass('invis').fadeOut(speed);
      // show hidden boxes
      $wall.children(colorClass+'.invis')
        .toggleClass('invis').fadeIn(speed);
    }
    $wall.masonry();
    return false;
  }); 

in order to change the default filter. Thanks

dimios avatar Mar 18 '11 19:03 dimios