Mark Chadwick on Wed Oct 12 16:17:50 2005


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Fwd: [PhillyOnRails] Scriptaculous Drag & Drop Problem

  • From: mark.chadwick@gmail.com (Mark Chadwick)
  • Subject: Fwd: [PhillyOnRails] Scriptaculous Drag & Drop Problem
  • Date: Wed Oct 12 16:17:50 2005

After a pretty intensive lunch break, I think an answer might be close. If
anybody woudln't mind giving it a poke, I put a copy of the test case up at:

http://sigel.ath.cx:8082/dnd-trouble/dnd-trouble.html
(only referring to the second problem)

Erin Mulder wrote:
> Okay... so this is similar to my clone-and-detach method (where I
> adjusted startDrag and stopDrag to clone the element and then attach it
> to body), but it has the same problem. If you are scrolled down in the
> scrollable div, the detached element shows up in the wrong place when
> you start dragging. (Basically, it uses the full offset instead of the
> scrollview offset.)

When explicit, it temporarily binds the dragging element to the body, and
the following changes to Position.cumulativeOffset take in to account the
position of any parent Divs of the dragging element.

cumulativeOffset: function(element) {
var valueT = 0, valueL = 0;

// These three lines
var offset = this.realOffset(element);
valueT -= offset[1];
valueL -= offset[0];

do {
valueT += element.offsetTop || 0;
valueL += element.offsetLeft || 0;
element = element.offsetParent;
} while (element);
return [valueL, valueT];
},


It still breaks in Safari, and there's a bit of flicker when starting and
stopping a drag, but those both can be tweaked. Let me know how it works for
you!

Thanks!
-Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://princetongames.org/pipermail/phillyonrails/attachments/20051012/172f5b6d/attachment.html