Filter & sort magical layouts http://isotope.metafizzy.co
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB

---
title: reLayout
layout: demo
category: demos
related: methods
---
<section id="copy">
<p>Use the <code>reLayout</code> method to easily arrange item elements after a change.</p>
<p>Click on any item element to change its size.</p>
</section>
<section id="options">
<ul>
<li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
</ul>
</section>
<div id="container" class="clickable clearfix">
{% for element in site.elements_ordered limit:20 %}
{% include element-partial.html %}
{% endfor %}
</div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script>
<script src="../jquery.isotope.js"></script>
<script>
$(function(){
var $container = $('#container');
// hacky way of adding random size classes
$container.find('.element').each(function(){
if ( Math.random() > 0.6 ) {
$(this).addClass('width2');
}
if ( Math.random() > 0.6 ) {
$(this).addClass('height2');
}
});
$container.isotope({
itemSelector: '.element',
masonry : {
columnWidth : 120
}
});
// toggle variable sizes of all elements
$('#toggle-sizes a').click(function(){
$container
.toggleClass('variable-sizes')
.isotope('reLayout');
return false;
});
// change size of clicked element
$container.find('.element').live('click', function(){
$(this).toggleClass('large');
// console.time('relayout');
$container.isotope('reLayout');
// console.timeEnd('relayout');
});
});
</script>
</body>
</html>