From 49f09f67b4c26c021735329703bf8ffdf92a110d Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Mon, 28 Mar 2011 09:55:14 -0400 Subject: [PATCH] src : reLayout : don't proceed unless there are atoms --- _posts/tests/2011-03-27-no-items01.html | 29 +++++++++++++++++++++++++ jquery.isotope.js | 12 ++++++++-- jquery.isotope.min.js | 8 +++---- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 _posts/tests/2011-03-27-no-items01.html 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});