I have two fixes in a text file.  I created the diff using "diff -u", so
I hope you can apply the patch.  The file is attached.

I never could get my optional 'scroll when the dragged element goes
outside the scrolled element' thing to work.  I got it to start
scrolling correctly, but then it would start making increasingly big
jumps and basically scroll out of control.  I removed all the code
associated with it.  Another issue I ran into is that my particular page
has 'position: relative' on the draggable elements.  IE cannot determine
size on relative or absolute positioned elements for some reason.  So, I
just gave up for the time being.  Anyone know of a way to get the width
and height on positioned elements in IE?

Anyway, the patch fixes it so that the dragged element moves with the
scroll, even when the mouse cursor leaves the document, and it now
passes the scrollSensitivity and scrollSpeed from Sortable to Draggable.

Greg
--- dragdrop.js 2006-03-22 12:54:18.000000000 -0700
+++ prototype/dragdrop.js       2006-03-22 14:44:47.000000000 -0700
@@ -412,6 +412,7 @@
     if(this.scrollInterval) {
       clearInterval(this.scrollInterval);
       this.scrollInterval = null;
+      Draggables._lastScrollPointer = null;
     }
   },
   
@@ -425,23 +426,26 @@
     var current = new Date();
     var delta = current - this.lastScrolled;
     this.lastScrolled = current;
+    var offset = [this.scrollSpeed[0] * delta / 1000, this.scrollSpeed[1] * 
delta / 1000];
     if(this.options.scroll.scrollTo) {
       with (this._getWindowScroll(this.options.scroll)) {
         if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
-          var d = delta / 1000;
-          this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + 
d*this.scrollSpeed[1] );
+          this.options.scroll.scrollTo( left + offset[0], top + offset[1] );
         }
       }
     } else {
-      this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
-      this.options.scroll.scrollTop  += this.scrollSpeed[1] * delta / 1000;
+      this.options.scroll.scrollLeft += offset[0];
+      this.options.scroll.scrollTop  += offset[1];
     }
     
     Position.prepare();
     Droppables.show(Draggables._lastPointer, this.element);
     Draggables.notify('onDrag', this);
-    this.draw(Draggables._lastPointer);    
-    
+    Draggables._lastScrollPointer = Draggables._lastScrollPointer || 
Draggables._lastPointer;
+    Draggables._lastScrollPointer[0] += offset[0];
+    Draggables._lastScrollPointer[1] += offset[1];
+    this.draw(Draggables._lastScrollPointer);
+
     if(this.options.change) this.options.change(this);
   },
   
@@ -524,6 +528,8 @@
       hoverclass:  null,
       ghosting:    false,
       scroll:      false,
+      scrollSensitivity: 20,
+      scrollSpeed: 15,
       format:      /^[^_]*_(.*)$/,
       onChange:    Prototype.emptyFunction,
       onUpdate:    Prototype.emptyFunction
@@ -538,7 +544,10 @@
       scroll:      options.scroll,
       ghosting:    options.ghosting,
       constraint:  options.constraint,
-      handle:      options.handle };
+      handle:      options.handle,
+      scrollSpeed: options.scrollSpeed,
+      scrollSensitivity: options.scrollSensitivity
+    };
 
     if(options.starteffect)
       options_for_draggable.starteffect = options.starteffect;
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to