Skip to content

Instantly share code, notes, and snippets.

@robbens
Created April 5, 2017 11:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbens/343d2d3ac5aa03b79a3bf17a482daad4 to your computer and use it in GitHub Desktop.
Save robbens/343d2d3ac5aa03b79a3bf17a482daad4 to your computer and use it in GitHub Desktop.
Example on how to use Masonry.js with FacetWP
// Init Masonry
var $grid = jQuery('.facetwp-template').masonry({
percentPosition: true,
columnWidth: '.grid-sizer',
itemSelector: '.grid-item'
});
// Reload and update on FacetWP load
jQuery(document).on('facetwp-loaded', function() {
$grid.masonry('reloadItems')
// Update Masonry layout after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment