我在 jquery isotope 插件中创建了 2 个新功能:
throwaway : function( $content, callback ) {
// remove elements immediately from Isotope instance
this.$allAtoms = this.$allAtoms.not( $content );
this.$filteredAtoms = this.$filteredAtoms.not( $content );
// remove() as a callback, for after transition / animation
var instance = this;
var removeContent = function() {
$('#trash-masonry').append( $content ).isotope( 'appended', $content );
setTimeout(function(){ $('#trash-masonry').isotope() }, 400);
setTimeout(function(){ $('#product-masonry').isotope() }, 400);
};
if ( $content.filter( ':not(.' + this.options.hiddenClass + ')' ).length ) {
// if any non-hidden content needs to be removed
this.styleQueue.push({ $el: $content, style: this.options.hiddenStyle });
this._sort();
this.reLayout( removeContent );
} else {
// remove it now
removeContent();
}
},
putback : function( $content, callback ) {
// remove elements immediately from Isotope instance
this.$allAtoms = this.$allAtoms.not( $content );
this.$filteredAtoms = this.$filteredAtoms.not( $content );
// remove() as a callback, for after transition / animation
var instance = this;
var removeContent = function() {
$('#product-masonry').append( $content ).isotope( 'appended', $content );
setTimeout(function(){ $('#trash-masonry').isotope() }, 400);
setTimeout(function(){ $('#product-masonry').isotope() }, 400);
};
if ( $content.filter( ':not(.' + this.options.hiddenClass + ')' ).length ) {
// if any non-hidden content needs to be removed
this.styleQueue.push({ $el: $content, style: this.options.hiddenStyle });
this._sort();
this.reLayout( removeContent );
} else {
// remove it now
removeContent();
}
},
和
$container.delegate( '.remove', 'click', function(){
var remove_id = $(this).data('item');
$container.isotope( 'throwaway',$('#' + remove_id) );
});
$trash.delegate( '.remove', 'click', function(){
var remove_id = $(this).data('item');
$trash.isotope( 'putback',$('#' + remove_id) );
});
奇迹般有效 :)