Skip to content

Commit

Permalink
after drag, sort by horizontal or vertical position
Browse files Browse the repository at this point in the history
  • Loading branch information
desandro committed Jan 28, 2014
1 parent d1018d6 commit 9563ce9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "packery",
"version": "1.2.1",
"version": "1.2.2",
"author": "David DeSandro / Metafizzy",
"description": "bin-packing layout library",
"main": [
Expand Down
15 changes: 10 additions & 5 deletions js/packery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Packery v1.2.1
* Packery v1.2.2
* bin-packing layout library
* http://packery.metafizzy.co
*
Expand Down Expand Up @@ -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 );
};

/**
Expand Down Expand Up @@ -322,7 +328,6 @@ Packery.prototype.itemDragMove = function( elem, x, y ) {

this.clearDragTimeout();

this.dragTimeout = setTimeout( delayed, 40 );
};

Packery.prototype.clearDragTimeout = function() {
Expand Down

0 comments on commit 9563ce9

Please sign in to comment.