Skip to content

Commit

Permalink
#271: * logic of auto-scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
RubaXa committed Feb 10, 2015
1 parent 64ec81a commit ab52c13
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ab52c13

Please sign in to comment.