From ca70fd7b9c42124dae409df324c99bd543aaaa74 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Wed, 22 Jan 2014 09:47:27 -0500 Subject: [PATCH] insert appends elements Fixes #607 --- examples/insert.html | 15 ++++++++------- js/isotope.js | 9 ++++++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/insert.html b/examples/insert.html index b611233..39f3c50 100644 --- a/examples/insert.html +++ b/examples/insert.html @@ -60,25 +60,26 @@ docReady( function() { } }); - function getAppendedItems() { - return [ appendItem(), appendItem(), appendItem() ]; - } - eventie.bind( document.querySelector('#insert'), 'click', function() { // append 3 new items - iso.insert( getAppendedItems() ); + iso.insert( [ getItem(), getItem(), getItem() ] ); }); eventie.bind( document.querySelector('#append'), 'click', function() { // append 3 new items - iso.appended( getAppendedItems() ); + iso.appended( [ appendItem(), appendItem(), appendItem() ] ); }); - function appendItem() { + function getItem() { var item = document.createElement('div'); item.className = 'item'; var num = Math.floor( Math.random() * 100 ); item.innerHTML = '' + num + ''; + return item; + } + + function appendItem() { + var item = getItem(); container.appendChild( item ); return item; } diff --git a/js/isotope.js b/js/isotope.js index 95223df..d9a6493 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -496,6 +496,13 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode if ( !items.length ) { 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 /* // this way adds hides new filtered items with NO transition @@ -516,7 +523,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode }); // */ // set flag - for ( var i=0, len = items.length; i < len; i++ ) { + for ( i=0; i < len; i++ ) { items[i].isLayoutInstant = true; } this.arrange();