DrewDahlman / Mason

Mason.js for creating a perfect grid with jQuery.
http://masonjs.com/
MIT License
1.22k stars 184 forks source link

Using Mason with hidden elements #41

Closed cabaret closed 9 years ago

cabaret commented 9 years ago

Since Mason does what Isotope/Packery seems unable to do, I switched to using this library. Thanks for the great work. However, I'm trying to implement some filtering and keep running into issues.

Whenever I hide elements with a certain class and run Mason, I get TypeError: Cannot set property 'x' of undefined, where x seems to be a semi-random number. I was hoping implementing my filter would be as simple as hiding the elements I don't need (thus only showing the elements I want in view) and running Mason again to get the positioning correct.

This is my config (CS):

@$el.mason
    itemSelector: @itemSelector
    ratio: 1.5,
    sizes: [
      [1, 2],
      [1, 1],
      [2, 2]
    ],
    promoted: [
      [1, 2, 'medium']
      [1, 1, 'small']
      [2, 2, 'large']
    ]
    layout: 'fluid',
    gutter: 0

All the elements I have are 'promoted', if I did not set that, I couldn't get the correct layout. Not sure about the ratio, I just stole that from somewhere :8ball:

Any help would be great. Thanks a lot.

DrewDahlman commented 9 years ago

Check out the v2 branch to see if this has fixed your issues. Also note that the order of promoted items has changed. it is now ['class_name', w, h]

https://github.com/DrewDahlman/Mason/tree/2.0