Created
August 7, 2017 19:19
-
-
Save FlowFX/7a6a076f9da6ed90e7dda1fa9a190065 to your computer and use it in GitHub Desktop.
This file contains 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
$( function() { | |
// init Isotope | |
var $container = $('#container'); | |
// init | |
$container.isotope({ | |
// options | |
itemSelector: '.item', | |
// layoutMode | |
masonry: { | |
columnWidth: '.item'/2 | |
} | |
}); | |
// store filter for each group | |
var filters = {}; | |
$('#filters').on( 'click', '.btn', function() { | |
var $this = $(this); | |
// get group key | |
var $buttonGroup = $this.parents('.btn-group'); | |
var filterGroup = $buttonGroup.attr('data-filter-group'); | |
// set filter for group | |
filters[ filterGroup ] = $this.attr('data-filter'); | |
// combine filters | |
var filterValue = ''; | |
for ( var prop in filters ) { | |
filterValue += filters[ prop ]; | |
} | |
// set filter for Isotope | |
$container.isotope({ filter: filterValue }); | |
}); | |
// change is-checked class on buttons | |
$('.btn-group').each( function( i, buttonGroup ) { | |
var $buttonGroup = $( buttonGroup ); | |
$buttonGroup.on( 'click', 'button', function() { | |
$buttonGroup.find('.active').removeClass('active'); | |
$( this ).addClass('active'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment