From 432a614ab6e01ea5bd8876a267de67a9ee3fd544 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 09 Apr 2009 15:38:50 -0400
Subject: [PATCH] - Fix drag&drop with scrolling on IE (#1485786)

---
 program/js/list.js |    2 +-
 CHANGELOG          |    1 +
 program/js/app.js  |   11 ++++++++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index ee805d1..a8960eb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Fix drag&drop with scrolling on IE (#1485786)
 - Fix adding signature separator in html mode (#1485350)
 - Fix opening attachment marks message as read (#1485803)
 - Fix 'temp_dir' does not support relative path under Windows (#1484529)
diff --git a/program/js/app.js b/program/js/app.js
index 51cce5d..7f60de5 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -53,7 +53,6 @@
   this.env.bin_path = './bin/';
   this.env.blankpage = 'program/blank.gif';
 
-
   // set environment variable(s)
   this.set_env = function(p, value)
     {
@@ -1182,6 +1181,9 @@
 
   this.drag_start = function(list)
   {
+       this.initialBodyScrollTop = bw.ie ? 0 : window.pageYOffset;
+       this.initialMailBoxScrollTop = document.getElementById("mailboxlist-container").scrollTop;
+
     var model = this.task == 'mail' ? this.env.mailboxes : this.env.address_sources;
 
     this.drag_active = true;
@@ -1213,10 +1215,17 @@
     {
     if (this.gui_objects.folderlist && this.env.folder_coords)
       {
+      // offsets to compensate for scrolling while dragging a message
+      var boffset = bw.ie ? -document.documentElement.scrollTop : this.initialBodyScrollTop;
+      var moffset = this.initialMailBoxScrollTop-document.getElementById('mailboxlist-container').scrollTop;
+      var toffset = -moffset-boffset;
+
       var li, pos, mouse;
       mouse = rcube_event.get_mouse_pos(e);
       pos = this.env.folderlist_coords;
 
+      mouse.y += toffset;
+
       // if mouse pointer is outside of folderlist
       if (mouse.x < pos.x1 || mouse.x >= pos.x2 
 	    || mouse.y < pos.y1 || mouse.y >= pos.y2)
diff --git a/program/js/list.js b/program/js/list.js
index 1fe493c..7bae7a5 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -774,7 +774,7 @@
   if (this.drag_active && this.draglayer)
   {
     var pos = rcube_event.get_mouse_pos(e);
-    this.draglayer.move(pos.x+20, pos.y-5);
+    this.draglayer.move(pos.x+20, bw.ie ? pos.y-5+document.documentElement.scrollTop : pos.y-5);
     this.trigger_event('dragmove', e);
   }
 

--
Gitblit v1.9.1