Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to toggle between Isotope's layout modes?

Two questions, everybody:

1) How do I toggle Isotope on and off?

2) How do I toggle layout modes? That is, how do I go from this:

 $('.content').isotope({  itemSelector : '.hentry',
                          layoutMode : 'cellsByRow',
                          cellsByRow : { columnWidth : 240, rowHeight : 360 } });

to this:

 $('.content').isotope({  itemSelector : '.hentry',
                          layoutMode : 'masonry'});

with a simple click switch? Any ideas?

Thanks!

like image 720
Tomer Lichtash Avatar asked Dec 22 '22 14:12

Tomer Lichtash


1 Answers

See http://jsfiddle.net/desandro/dbgFa/

1) To disable Isotope after initializing it, use the destroy method

$('.content').isotope('destroy')

Then turn it back on by triggering Isotope again

$('.content').isotope( /* options */ )

2) You would change layout modes just like your example code, by setting the layoutMode in the options. This will also trigger a re-layout and the layout will change.

like image 63
desandro Avatar answered Jan 05 '23 08:01

desandro