Fix dragging in scrolled view correctly.
authorJan Schneider <jan@horde.org>
Sat, 10 Jul 2010 09:47:19 +0000 (11:47 +0200)
committerJan Schneider <jan@horde.org>
Sat, 10 Jul 2010 09:47:54 +0000 (11:47 +0200)
kronolith/js/kronolith.js

index 1a5ac64..be83ef5 100644 (file)
@@ -1850,7 +1850,7 @@ KronolithCore = {
 
                 if (draggerTop) {
                     opts.snap = function(x, y) {
-                        y = Math.max(0, step * (Math.min(maxTop, y) / step | 0)) - this.scrollTop;
+                        y = Math.max(0, step * (Math.min(maxTop, y - this.scrollTop) / step | 0));
                         return [0, y];
                     }.bind(this);
                     var d = new Drag(event.value.nodeId + 'top', opts);
@@ -1864,7 +1864,7 @@ KronolithCore = {
 
                 if (draggerBottom) {
                     opts.snap = function(x, y) {
-                        y = Math.min(maxBottom + dragBottomHeight + KronolithCore[storage].spacing, step * ((Math.max(minBottom, y) + dragBottomHeight + KronolithCore[storage].spacing) / step | 0)) - dragBottomHeight - KronolithCore[storage].spacing - this.scrollTop;
+                        y = Math.min(maxBottom + dragBottomHeight + KronolithCore[storage].spacing, step * ((Math.max(minBottom, y - this.scrollTop) + dragBottomHeight + KronolithCore[storage].spacing) / step | 0)) - dragBottomHeight - KronolithCore[storage].spacing;
                         return [0, y];
                     }.bind(this);
                     var d = new Drag(event.value.nodeId + 'bottom', opts);
@@ -1890,7 +1890,7 @@ KronolithCore = {
                         x = (view == 'week')
                             ? Math.max(minLeft, stepX * ((Math.min(maxLeft, x - (x < 0 ? stepX : 0)) + stepX / 2) / stepX | 0))
                             : 0;
-                        y = Math.max(0, step * (Math.min(maxDiv, y) / step | 0)) - this.scrollTop;
+                        y = Math.max(0, step * (Math.min(maxDiv, y - this.scrollTop) / step | 0));
                         return [x, y];
                     }.bind(this)
                 });