Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active February 5, 2021 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/7e4e38528475ed52140fac5ecdf4de62 to your computer and use it in GitHub Desktop.
Save wplit/7e4e38528475ed52140fac5ecdf4de62 to your computer and use it in GitHub Desktop.
isotope code from Elijah's code, ammended to ensure filters work with the Infinite Scroller component.
jQuery(document).ready( function() {
var $grid = jQuery('.grid').isotope({
itemSelector: '.grid-item',
layoutMode: 'fitRows',
getSortData: {
title: '.title',
date: '.date'
}
})
jQuery('.category').each( function() {
jQuery(this).closest('.grid-item').addClass(jQuery(this).text().toLowerCase());
jQuery(this).remove();
})
jQuery('[data-filter]').click( function(e) {
e.preventDefault();
$grid.isotope({ filter: jQuery(this).data('filter') })
})
jQuery('[data-sortby]').click( function(e) {
e.preventDefault();
$grid.isotope({ sortBy: jQuery(this).data('sortby') })
});
/* Addng the classes again on the append.infiniteScroll event */
jQuery('.grid').on( 'append.infiniteScroll', function( event, body, path, items, response ) {
jQuery('.category').each( function() {
jQuery(this).closest('.grid-item').addClass(jQuery(this).text().toLowerCase());
jQuery(this).remove();
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment