Skip to content

Instantly share code, notes, and snippets.

@johno
Created October 17, 2013 22:16
Show Gist options
  • Save johno/7033263 to your computer and use it in GitHub Desktop.
Save johno/7033263 to your computer and use it in GitHub Desktop.
Unobtrusive masonry for http://masonry.desandro.com/.
<div class="masonry" data-masonry-element="widget" data-masonry-gutter=20>
<!-- ... -->
</div>
$(function() {
$('.masonry').each(function(index, container) {
container = $(container);
isFitWidth = container.data("masonry-fit-width");
itemSelector = container.data("masonry-element");
gutter = container.data("masonry-gutter");
container.masonry({
itemSelector: "." + itemSelector,
"isFitWidth": isFitWidth ? true : false,
"gutter": gutter ? gutter : 0,
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment