diff --git a/bower.json b/bower.json index 12c17d1..5bbaa92 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "main": "js/isotope.js", "dependencies": { "desandro-matches-selector": "^2.0.0", - "fizzy-ui-utils": "^2.0.0", + "fizzy-ui-utils": "^2.0.4", "get-size": "^2.0.0", "masonry": "^4.1.0", "outlayer": "^2.1.0" diff --git a/js/isotope.js b/js/isotope.js index e6dce52..b914a89 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -402,20 +402,28 @@ var trim = String.prototype.trim ? // sort filteredItem order proto._sort = function() { - var sortByOpt = this.options.sortBy; - if ( !sortByOpt ) { + if ( !this.options.sortBy ) { return; } - // concat all sortBy and sortHistory - var sortBys = [].concat.apply( sortByOpt, this.sortHistory ); + // keep track of sortBy History + var sortBys = utils.makeArray( this.options.sortBy ); + if ( !this._getIsSameSortBy( sortBys ) ) { + // concat all sortBy and sortHistory, add to front, oldest goes in last + this.sortHistory = sortBys.concat( this.sortHistory ); + } // sort magic - var itemSorter = getItemSorter( sortBys, this.options.sortAscending ); + var itemSorter = getItemSorter( this.sortHistory, this.options.sortAscending ); this.filteredItems.sort( itemSorter ); - // keep track of sortBy History - if ( sortByOpt != this.sortHistory[0] ) { - // add to front, oldest goes in last - this.sortHistory.unshift( sortByOpt ); + }; + + // check if sortBys is same as start of sortHistory + proto._getIsSameSortBy = function( sortBys ) { + for ( var i=0; i < sortBys.length; i++ ) { + if ( sortBys[i] != this.sortHistory[i] ) { + return false; + } } + return true; }; // returns a function used for sorting diff --git a/package.json b/package.json index 0949a6d..2f61702 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "js/isotope.js", "dependencies": { "desandro-matches-selector": "^2.0.0", - "fizzy-ui-utils": "^2.0.0", + "fizzy-ui-utils": "^2.0.4", "get-size": "^2.0.0", "masonry-layout": "^4.0.0", "outlayer": "^2.1.0" diff --git a/test/index.html b/test/index.html index cce4eea..f6509ae 100644 --- a/test/index.html +++ b/test/index.html @@ -56,6 +56,17 @@