Browse Source

#271: * logic of auto-scrolling

scroll
RubaXa 10 years ago
parent
commit
ab52c13850
  1. 20
      Sortable.js

20
Sortable.js

@ -424,20 +424,28 @@
winWidth = window.innerWidth, winWidth = window.innerWidth,
winHeight = window.innerHeight, winHeight = window.innerHeight,
vx = (winWidth - x <= sens) - (x <= sens), vx,
vy = (winHeight - y <= sens) - (y <= sens) vy
; ;
if (vx || vy) {
el = win; if (scrollEl) {
}
else if (scrollEl) {
el = scrollEl; el = scrollEl;
rect = scrollEl.getBoundingClientRect(); rect = scrollEl.getBoundingClientRect();
vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens); vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens);
vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= 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) { if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) {
autoScroll.el = el; autoScroll.el = el;
autoScroll.vx = vx; autoScroll.vx = vx;

Loading…
Cancel
Save