When I click an item it expands. When I click another item it also expands but leaves the first one expanded too. I only want one item expanded at any time ie: the one I click on. So I need to basically toggle everything to it's original state and then only expand the one I actually click on. There is a codepen for the example I am using.
// external js: masonry.pkgd.js
var $grid = $('.grid').masonry({
columnWidth: 120,
itemSelector: '.grid-item'
});
$grid.on( 'click', '.grid-item-content', function( event ) {
$( event.currentTarget ).parent('.grid-item').toggleClass('is-expanded');
$grid.masonry();
});
See the Pen Masonry - animate item size by Dave DeSandro (@desandro) on CodePen.