clonePosition() doesn't work in IE if an element is not attached to the
authorJan Schneider <jan@horde.org>
Mon, 7 Jun 2010 15:51:01 +0000 (17:51 +0200)
committerJan Schneider <jan@horde.org>
Mon, 7 Jun 2010 16:07:12 +0000 (18:07 +0200)
body. Since the dragger is always positioned absolutely, we know the offset
parent anyway and can calculate the position manually.

horde/js/dragdrop2.js

index f7b0a7a..f80feab 100644 (file)
@@ -309,7 +309,7 @@ Drag = Class.create({
 
     _mouseMove: function(e)
     {
-        var go, so, eo, po, xy, int;
+        var go, eo, po, xy, p, delta, int;
 
         if (++this.move <= this.options.threshold) {
             return;
@@ -332,8 +332,14 @@ Drag = Class.create({
                 this.ghost = $(this.element.cloneNode(true))
                     .writeAttribute('id', null)
                     .addClassName(this.options.classname)
-                    .setStyle({ position: 'absolute', height: layout.get('height') + 'px', width: layout.get('width') + 'px' })
-                    .clonePosition(this.element, { setHeight: false, setWidth: false });
+                    .setStyle({ position: 'absolute', height: layout.get('height') + 'px', width: layout.get('width') + 'px' });
+
+                var p = this.element.viewportOffset();
+                var delta = document.body.viewportOffset();
+                delta[0] -= document.body.offsetLeft;
+                delta[1] -= document.body.offsetTop;
+                this.ghost.style.left = (p[0] - delta[0]) + 'px';
+                this.ghost.style.top  = (p[1] - delta[1]) + 'px';
 
                 // eo is the offset of the original element to the body.
                 eo = this.element.cumulativeOffset();
@@ -404,11 +410,6 @@ Drag = Class.create({
                 }
             }
 
-            // This is called on each mouse move. Get the current scrolling
-            // offset of the ghost, i.e. how far the ghost's parents have
-            // been scrolled.
-            so = this.ghost.cumulativeScrollOffset();
-
             // Subtract the ghost's offset to the original mouse position and
             // add any scrolling.
             xy[0] -= this.mouseOffset[0];