我的目标是将函数放在setupSorting
函数内部ImageLoad
。它们在分开时起作用(此处),但在组合时排序失败(此处)。
这个:
$(document).ready (function(){
/* reshuffle when user clicks a filter item */
$('.filter-tags a').click(function (e) {
e.preventDefault();
// set active class
$('.filter-tags a').removeClass('active');
$(this).addClass('active');
// get group name from clicked item
var groupName = $(this).attr('data-group');
// reshuffle grid
$grid.shuffle('shuffle', groupName );
});
需要进入这个:
var ImageLoad = (function( $, imagesLoaded ) {
var $shuffle = $('.masonry-gallery'),
$imgs = $shuffle.find('img'),
$loader = $('#loader'),
sizer = document.getElementById('#shuffle-sizer'),
imgLoad,
init = function() {
// Create a new imagesLoaded instance
imgLoad = new imagesLoaded( $imgs.get() );
// Listen for when all images are done
// will be executed even if some images fail
imgLoad.on( 'always', onAllImagesFinished );
},
onAllImagesFinished = function( instance ) {
if ( window.console && window.console.log ) {
console.log( instance );
}
// Hide loader
$loader.addClass('hidden');
// Adds visibility: visible;
$shuffle.addClass('images-loaded');
// Initialize shuffle
$shuffle.shuffle({
sizer: sizer,
itemSelector: '.gallery-photo'
});
};
return {
init: init
};
}( jQuery, window.imagesLoaded ));
$(document).ready(function() {
ImageLoad.init();
});
最终目标是喜欢这个页面,只有排序:http: //vestride.github.io/Shuffle/images/