diff --git a/bower.json b/bower.json index 97abcff..0476b97 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "packery", - "version": "1.2.1", + "version": "1.2.2", "author": "David DeSandro / Metafizzy", "description": "bin-packing layout library", "main": [ diff --git a/js/packery.js b/js/packery.js index bc378f6..cf97e87 100644 --- a/js/packery.js +++ b/js/packery.js @@ -1,5 +1,5 @@ /*! - * Packery v1.2.1 + * Packery v1.2.2 * bin-packing layout library * http://packery.metafizzy.co * @@ -190,11 +190,17 @@ Packery.prototype._manageStamp = function( elem ) { // -------------------------- methods -------------------------- // +function verticalSorter( a, b ) { + return a.position.y - b.position.y || a.position.x - b.position.x; +} + +function horizontalSorter( a, b ) { + return a.position.x - b.position.x || a.position.y - b.position.y; +} Packery.prototype.sortItemsByPosition = function() { - this.items.sort( function( a, b ) { - return a.position.y - b.position.y || a.position.x - b.position.x; - }); + var sorter = this.options.isHorizontal ? horizontalSorter : verticalSorter; + this.items.sort( sorter ); }; /** @@ -322,7 +328,6 @@ Packery.prototype.itemDragMove = function( elem, x, y ) { this.clearDragTimeout(); - this.dragTimeout = setTimeout( delayed, 40 ); }; Packery.prototype.clearDragTimeout = function() {