ericabouaf / wireit

A javascript wiring library to create web wirable interfaces for dataflow applications, visual programming languages or graphical modeling.
http://neyric.github.io/wireit/docs/
Other
520 stars 90 forks source link

Scrolled offset div wiring problem #27

Closed ghost closed 14 years ago

ghost commented 14 years ago

There is a bug when the wireit div is offset on the page. The wire endpoint when dragging is offset by the amount of the offset in the div. I have an example html file and a patch.

ghost commented 14 years ago

Here is the patch...


diff --git a/js/Terminal.js b/js/Terminal.js
index b0074ef..23c142b 100644
--- a/js/Terminal.js
+++ b/js/Terminal.js
@@ -242,16 +242,16 @@ lang.extend(WireIt.TerminalProxy, util.DDProxy, {

       if(this.terminal.container) {
          var obj = this.terminal.container.layer.el;
-         var curleft = curtop = 0;
+         var curleft = 0;
+         var curtop = 0;
                if (obj.offsetParent) {
                        do {
-                               curleft += obj.offsetLeft;
-                               curtop += obj.offsetTop;
+                               curleft += obj.scrollLeft;
+                               curtop += obj.scrollTop;
                                obj = obj.offsetParent ;
-                       } while ( obj = obj.offsetParent );
+                       } while ( obj );
                }
-         this.fakeTerminal.pos = [e.clientX-curleft+this.terminal.container.layer.el.scrollLeft,
-                                  e.clientY-curtop+this.terminal.container.layer.el.scrollTop];
+         this.fakeTerminal.pos = [e.clientX+curleft, e.clientY+curtop];
       }
       else {
          this.fakeTerminal.pos = (YAHOO.env.ua.ie) ? [e.clientX, e.clientY] : [e.clientX+window.pageXOffset, e.clientY+window.pageYOffset];

ericabouaf commented 14 years ago

yeah, finally fixed on the edge branch ! http://github.com/neyric/wireit/commit/56e4a212b5f5687634f0254057f790670c1bb77e Thanks !