Isotope - centered & without corner-stamp
HTML
<script src="http://isotope.metafizzy.co/jquery.isotope.min.js"></script>
<ul id="filters">
<li><a href="#" data-filter="*">show all</a></li>
<li><a href="#" data-filter=".blue">blue</a></li>
<li><a href="#" data-filter=".red">red</a></li>
<li><a href="#" data-filter=".green">green</a></li>
<li><a href="#" data-filter=".orange, .yellow">orange & yellow</a></li>
</ul>
<div id="container">
<div class="item "></div>
<!--<div class="corner-stamp right"></div>-->
<div class="item blue"></div>
<div class="item red"></div>
<div class="item orange"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item blue"></div>
<div class="item red"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item blue"></div>
<div class="item red"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item red"></div>
<div class="item orange"></div>
<div class="item blue"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item blue"></div>
<div class="item red"></div>
<div class="item green"></div>
<div class="item yellow"></div>
<div class="item orange"></div>
<div class="item green"></div>
<div class="item yellow"></div>
</div>
CSS
body { font-family: sans-serif; }
#filters { margin-bottom: 1.0em; }
#filters li {
display: inline-block;
}
#filters li a {
background: blue;
color: white;
padding: 2px;
display: block;
}
#filters li a:hover {
color: red;
background: yellow;
}
#container {
border: 2px solid;
padding: 5px;
}
.item {
width: 90px;
height: 50px;
margin-bottom:10px;
}
.blue { background: blue; }
.red { background: red; }
.orange { background: orange; }
.green { background: green; }
.yellow { background: yellow; }
.corner-stamp {
width: 210px;
height: 50px;
background: #888;
margin-bottom:10px;
}
.corner-stamp.left {
float:left;
}
.corner-stamp.right{
float:right;
}
/* Start: Recommended Isotope styles */
/**** Isotope Filtering ****/
.isotope-item {
z-index: 2;
}
.isotope-hidden.isotope-item {
pointer-events: none;
z-index: 1;
}
/**** Isotope CSS3 transitions ****/
.isotope,
.isotope .isotope-item {
-webkit-transition-duration: 0.8s;
-moz-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
transition-duration: 0.8s;
}
.isotope {
-webkit-transition-property: height, width;
-moz-transition-property: height, width;
-o-transition-property: height, width;
transition-property: height, width;
}
.isotope .isotope-item {
-webkit-transition-property: -webkit-transform, opacity;
-moz-transition-property: -moz-transform, opacity;
-o-transition-property: top, left, opacity;
transition-property: transform, opacity;
}
/**** disabling Isotope CSS3 transitions ****/
.isotope.no-transition,
.isotope.no-transition .isotope-item,
.isotope .isotope-item.no-transition {
-webkit-transition-duration: 0s;
-moz-transition-duration: 0s;
-o-transition-duration: 0s;
transition-duration: 0s;
}
/* End: Recommended Isotope styles */
JavaScript
$(function(){
var $container = $('#container');
$container.isotope({
itemSelector: '.item',
resizesContainer:true,
masonry: {
columnWidth: 100,
gutterWidth: 10,
cornerStampSelector : '.corner-stamp'
}
});
$('#filters').on( 'click', 'a', function() {
var selector = $(this).data('filter');
if ( selector !== '*' ) {
// include corner-stamp in filter
// so it never gets filtered out
selector = selector + ', .corner-stamp'
}
$container.isotope({ filter: selector });
});
$.Isotope.prototype._getCenteredMasonryColumns = function() {
this.width = this.element.width();
var parentWidth = this.element.parent().width();
// i.e. options.masonry && options.masonry.columnWidth
var colW = this.options.masonry && this.options.masonry.columnWidth ||
// or use the size of the first item
this.$filteredAtoms.outerWidth(true) ||
// if there's no items, use size of container
parentWidth;
var cols = Math.floor( parentWidth / colW );
cols = Math.max( cols, 1 );
// i.e. this.masonry.cols = ....
this.masonry.cols = cols;
// i.e. this.masonry.columnWidth = ...
this.masonry.columnWidth = colW;
};
$.Isotope.prototype._masonryReset = function() {
// layout-specific props
this.masonry = {};
// FIXME shouldn't have to call this again
this._getCenteredMasonryColumns();
var i = this.masonry.cols;
this.masonry.colYs = [];
while (i--) {
this.masonry.colYs.push( 0 );
};
//corner-stamp
if ( this.options.masonry.cornerStampSelector ) {
var $cornerStamp = this.element.find( this.options.masonry.cornerStampSelector ),
stampWidth = $cornerStamp.outerWidth(true) - (...