diff --git a/_posts/tests/2011-03-27-no-items01.html b/_posts/tests/2011-03-27-no-items01.html new file mode 100644 index 0000000..4eaf1be --- /dev/null +++ b/_posts/tests/2011-03-27-no-items01.html @@ -0,0 +1,29 @@ +--- +title: no items01 +layout: demo +category: tests +--- + +
+

After destroy-ing Isotope, original CSS gets re-applied

+
+ +
+ {% for element in site.elements limit:20 %} + {% include element-partial.html %} + {% endfor %} +
+ + + + \ No newline at end of file diff --git a/jquery.isotope.js b/jquery.isotope.js index 2370e31..89bfe04 100644 --- a/jquery.isotope.js +++ b/jquery.isotope.js @@ -652,8 +652,16 @@ reLayout : function( callback ) { - return this[ '_' + this.options.layoutMode + 'Reset' ]() - .layout( this.$filteredAtoms, callback ); + + // proceed if there are atoms + if ( this.$allAtoms.length && this.$filteredAtoms.length ) { + return this[ '_' + this.options.layoutMode + 'Reset' ]() + .layout( this.$filteredAtoms, callback ); + } else { + // TO DO: add callback.call here? + return this; + } + }, // ====================== Convenience methods ====================== diff --git a/jquery.isotope.min.js b/jquery.isotope.min.js index 81361cb..6682891 100644 --- a/jquery.isotope.min.js +++ b/jquery.isotope.min.js @@ -21,10 +21,10 @@ a.scale?a.scale:1}};f.fx.step.scale=function(a){f.cssHooks.scale.set(a.elem,a.no f.extend(true,this.options,a);else if(a&&typeof b==="undefined")return this.options[a];else this.options[a]=b;return this},_setupAtoms:function(a){var b={position:"absolute"};if(this.usingTransforms){b.left=0;b.top=0}a.css(b).addClass(this.options.itemClass);this.updateSortData(a,true)},_filter:function(a){var b=this.options.filter===""?"*":this.options.filter;if(b){var c=this.options.hiddenClass,d="."+c,e=a.not(d),g=a.filter(d);d=g;a=a.filter(b);if(b!=="*"){d=g.filter(b);b=e.not(b).toggleClass(c); b.addClass(c);this.styleQueue.push({$el:b,style:this.options.hiddenStyle})}this.styleQueue.push({$el:d,style:this.options.visibleStyle});d.removeClass(c)}return a},updateSortData:function(a,b){var c=this,d=this.options.getSortData,e,g;a.each(function(){e=f(this);g={};for(var h in d)g[h]=d[h](e,c);e.data("isotope-sort-data",g);b&&c.elemCount++})},_sort:function(){var a=this,b=function(d){return f(d).data("isotope-sort-data")[a.options.sortBy]},c=this.options.sortAscending?1:-1;this.$filteredAtoms.sort(function(d, e){var g=b(d),h=b(e);return(g>h?1:gb.width){b.fitRows.x=0;b.fitRows.y=b.fitRows.height}b._pushPosition(c,b.fitRows.x+b.posLeft,b.fitRows.y+b.posTop);b.fitRows.height=Math.max(b.fitRows.y+e,b.fitRows.height);b.fitRows.x+=d});