Browse Source

src : move remove callback into removeContent

add add/remove button to remove demo

v1.5.15

Closes #139
pull/166/merge v1.5.15
David DeSandro 13 years ago
parent
commit
40b3232d8d
  1. 23
      _posts/demos/2011-12-22-removing.html
  2. 11
      jquery.isotope.js
  3. 4
      jquery.isotope.min.js

23
_posts/demos/2011-12-22-removing.html

@ -23,6 +23,9 @@ category: demos
<li><a href="#remove" data-option-value=".metalloid">metalloid</a></li>
</ul>
<ul id="add-remove">
<li><a href="#add-remove">Add / remove</a></li>
</ul>
</section> <!-- #options -->
@ -34,6 +37,7 @@ category: demos
<script src="../{{ site.jquery_js }}"></script>
<script src="../{{ site.isotope_js }}"></script>
<script src="../js/fake-element.js"></script>
<script>
$(function(){
@ -43,10 +47,26 @@ category: demos
itemSelector : '.element'
});
$('#removable a').click(function(){
$('#removable a').click( function( jQEvent ) {
var selector = $(this).attr('data-option-value');
var $removable = $container.find( selector );
$container.isotope( 'remove', $removable );
jQEvent.preventDefault();
});
$('#add-remove a').click( function( jQEvent ) {
var $newEls = $( fakeElement.getGroup() );
var $firstTwoElems = $container.data('isotope')
.$filteredAtoms.filter( function( i ) {
return i < 2;
});
$container
.isotope( 'insert', $newEls )
.isotope( 'remove', $firstTwoElems, function() {
// console.log('items removed')
});
jQEvent.preventDefault();
});
// remove item if clicked
@ -54,7 +74,6 @@ category: demos
$container.isotope( 'remove', $(this) );
});
});
</script>

11
jquery.isotope.js

@ -1,5 +1,5 @@
/**
* Isotope v1.5.14
* Isotope v1.5.15
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
@ -806,9 +806,13 @@
remove: function( $content, callback ) {
// remove elements from Isotope instance in callback
var instance = this;
// remove() as a callback, for after transition / animation
var removeContent = function() {
instance.$allAtoms = instance.$allAtoms.not( $content );
$content.remove();
if ( callback ) {
callback.call( this.element );
}
};
if ( $content.filter( ':not(.' + this.options.hiddenClass + ')' ).length ) {
@ -816,13 +820,10 @@
this.styleQueue.push({ $el: $content, style: this.options.hiddenStyle });
this.$filteredAtoms = this.$filteredAtoms.not( $content );
this._sort();
this.reLayout( removeContent, callback );
this.reLayout( removeContent );
} else {
// remove it now
removeContent();
if ( callback ) {
callback.call( this.element );
}
}
},

4
jquery.isotope.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save