Last active
February 5, 2021 23:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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