Browse Source

insert appends elements

Fixes #607
pull/726/head
David DeSandro 11 years ago
parent
commit
ca70fd7b9c
  1. 15
      examples/insert.html
  2. 9
      js/isotope.js

15
examples/insert.html

@ -60,25 +60,26 @@ docReady( function() {
} }
}); });
function getAppendedItems() {
return [ appendItem(), appendItem(), appendItem() ];
}
eventie.bind( document.querySelector('#insert'), 'click', function() { eventie.bind( document.querySelector('#insert'), 'click', function() {
// append 3 new items // append 3 new items
iso.insert( getAppendedItems() ); iso.insert( [ getItem(), getItem(), getItem() ] );
}); });
eventie.bind( document.querySelector('#append'), 'click', function() { eventie.bind( document.querySelector('#append'), 'click', function() {
// append 3 new items // append 3 new items
iso.appended( getAppendedItems() ); iso.appended( [ appendItem(), appendItem(), appendItem() ] );
}); });
function appendItem() { function getItem() {
var item = document.createElement('div'); var item = document.createElement('div');
item.className = 'item'; item.className = 'item';
var num = Math.floor( Math.random() * 100 ); var num = Math.floor( Math.random() * 100 );
item.innerHTML = '<b>' + num + '</b>'; item.innerHTML = '<b>' + num + '</b>';
return item;
}
function appendItem() {
var item = getItem();
container.appendChild( item ); container.appendChild( item );
return item; return item;
} }

9
js/isotope.js

@ -496,6 +496,13 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
if ( !items.length ) { if ( !items.length ) {
return; return;
} }
// append item elements
var i, item;
var len = items.length;
for ( i=0; i < len; i++ ) {
item = items[i];
this.element.appendChild( item.element );
}
// filter new stuff // filter new stuff
/* /*
// this way adds hides new filtered items with NO transition // this way adds hides new filtered items with NO transition
@ -516,7 +523,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
}); });
// */ // */
// set flag // set flag
for ( var i=0, len = items.length; i < len; i++ ) { for ( i=0; i < len; i++ ) {
items[i].isLayoutInstant = true; items[i].isLayoutInstant = true;
} }
this.arrange(); this.arrange();

Loading…
Cancel
Save