"sample gallery 2"
Bootstrap 3.3.0 Snippet by neunygph

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<h1>Masonry + imagesLoaded, iteratively reveal items</h1>
<div id="container"></div>
<div id="images">
<div class="item">
<img src="http://lorempixel.com/425/299/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/190/292/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/520/329/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/404/176/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/530/290/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/228/200/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/207/316/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/435/162/nature">
</div>
<div class="item">
<img src="http://lorempixel.com/376/175/nature">
</div>
<div class="item">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
body {
font-family: sans-serif;
}
#container {
background: #DDD;
max-width: 1000px;
}
.item {
width: 200px;
float: left;
}
.item img {
display: block;
width: 100%;
}
button {
font-size: 18px;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$(function () {
var $container = $('#container').masonry({
itemSelector: '.item',
columnWidth: 200
});
// reveal initial images
$container.masonryImagesReveal($('#images').find('.item'));
});
$.fn.masonryImagesReveal = function ($items) {
var msnry = this.data('masonry');
var itemSelector = msnry.options.itemSelector;
// hide by default
$items.hide();
// append to container
this.append($items);
$items.imagesLoaded().progress(function (imgLoad, image) {
// get item
// image is imagesLoaded class, not <img>, <img> is image.img
var $item = $(image.img).parents(itemSelector);
// un-hide item
$item.show();
// masonry does its thing
msnry.appended($item);
});
return this;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: