Skip to content

Instantly share code, notes, and snippets.

@vumanhcuongit
Created February 2, 2013 05:12
Show Gist options
  • Select an option

  • Save vumanhcuongit/4696190 to your computer and use it in GitHub Desktop.

Select an option

Save vumanhcuongit/4696190 to your computer and use it in GitHub Desktop.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="jquery.masonry.min.js" type="text/javascript"></script>
<script src="jquery.infinitescroll.min.js" type="text/javascript"></script> // thu vien moi, luu y: xep dang sau masonry.min.js
<script type="text/Javascript">
$(document).ready(function () {
init();
});
function init() {
var $container = $('#container');
$container.imagesLoaded( function(){
$container.masonry({
itemSelector : '.box'
});
});
// PHAN MOI THEM VAO
$container.infinitescroll({
navSelector : '#page-nav', // selector for the paged navigation
nextSelector : '#page-nav a', // selector for the NEXT link (to page 2)
itemSelector : '.box', // selector for all items you'll retrieve
loading: {
finishedMsg: 'No more pages to load.',
msgText: "<em>Loading the next set of images...</em>"
}
},
// trigger Masonry as a callback
function( newElements ) {
// hide new items while they are loading
var $newElems = $( newElements ).css({ opacity: 0 });
// ensure that images load before adding to masonry layout
$newElems.imagesLoaded(function(){
// show elems now they're ready
$newElems.animate({ opacity: 1 });
$container.masonry( 'appended', $newElems, true );
});
}
);
//end func
}
</script>
/* PHAN CHUA HINH */
<div id="container">
<div class="box photo col3 masonry-brick" >
<a href="http://www.facebook.com/photo.php?fbid=3862598492298&amp;set=a.1461090096089.63286.1498535627&amp;type=1">
<img alt="526779_3862598492298_1890594693_n" src="https://sphotos-a.xx.fbcdn.net/hphotos-ash3/s720x720/526779_3862598492298_1890594693_n.jpg" />
</a>
</div>
<div class="box photo col3 masonry-brick" >
<a href="http://www.facebook.com/photo.php?fbid=3862598492298&amp;set=a.1461090096089.63286.1498535627&amp;type=1">
<img alt="526779_3862598492298_1890594693_n" src="https://sphotos-a.xx.fbcdn.net/hphotos-ash3/s720x720/526779_3862598492298_1890594693_n.jpg" />
</a>
</div>
</div>
<!-- contains the content to be loaded when scrolled -->
<nav id="page-nav">
<a href="pages/2.html"></a> /* Nhung link da paginate*/
<a href="pages/3.html"></a>
</nav>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment