From ab52c138509968f1c85dd2c3d5205a85e54ef797 Mon Sep 17 00:00:00 2001 From: RubaXa Date: Tue, 10 Feb 2015 23:20:37 +0300 Subject: [PATCH] #271: * logic of auto-scrolling --- Sortable.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Sortable.js b/Sortable.js index 19c504aee..ac34a5b0c 100644 --- a/Sortable.js +++ b/Sortable.js @@ -424,20 +424,28 @@ winWidth = window.innerWidth, winHeight = window.innerHeight, - vx = (winWidth - x <= sens) - (x <= sens), - vy = (winHeight - y <= sens) - (y <= sens) + vx, + vy ; - if (vx || vy) { - el = win; - } - else if (scrollEl) { + + if (scrollEl) { el = scrollEl; rect = scrollEl.getBoundingClientRect(); vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens); vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens); } + + if (!(vx || vy)) { + vx = (winWidth - x <= sens) - (x <= sens); + vy = (winHeight - y <= sens) - (y <= sens); + + /* jshint expr:true */ + (vx || vy) && (el = win); + } + + if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) { autoScroll.el = el; autoScroll.vx = vx;