From ddc0ac3aafa71944c69110ba0bcb17aeaa71cde7 Mon Sep 17 00:00:00 2001 From: Alex Bardanov Date: Mon, 25 Aug 2014 13:36:35 +0300 Subject: [PATCH] fix tabs drag and drop behavior, #8 --- bindings/drag.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bindings/drag.js b/bindings/drag.js index 1e42190..12b176f 100644 --- a/bindings/drag.js +++ b/bindings/drag.js @@ -34,9 +34,18 @@ define(function(require, exports){ })), whereIndex = _.indexOf(workingSet, _.find(workingSet, function(el){ return el._path === where; - })); + })), + diff = whereIndex - whoIndex, + direction = diff / Math.abs(diff); - DocumentManager.swapWorkingSetIndexes(whoIndex, whereIndex); + if (Math.abs(diff) <= 1){ + DocumentManager.swapWorkingSetIndexes(whoIndex, whereIndex); + } else { + while(whoIndex !== whereIndex){ + DocumentManager.swapWorkingSetIndexes(whoIndex, whereIndex); + whereIndex -= direction; + } + } dragWho = null; dragWhere = null;