Issue 163: drag and drop markers: offset is sometimes calculated incorrectly
Status:  Verified
Owner:
Closed:  Nov 2010
Reported by cbattare...@gmail.com, Nov 15, 2010
First thanks for this greay tool !

I'm currently implementing it in the Yacs CMS (www.yacs.fr) and i've
made some corrections for the drag and drop support.

First correction is for the case that the tree is in a container and not directly
under the body level.

In this case, the tree may not be in position 0,0, so you have to be
careful of the conainer offset while determining the hitmode in the
_onDragEvent function.

You also have to append the dndMarker to the container of the tree and
not directly on the body tag, otherwise it won't be on current
position.

So here are the changes i've made and i'd like you to integrate in
your code :

 - line 1930 in the initialize function of the tree :
    var parentPos = $(this.divTree).parent().offset();
    this.parentTop = parentPos.top;
    this.parentLeft = parentPos.left;
to memorize the parent offset.

- line 2401 (line 2397 in the original source) :
   .prependTo($(this.divTree).parent()); // instead
of .prependTo("body");

- line 2543 (after line 2538 in the original source) :
   nodeOfs.top += this.parentTop;
   nodeOfs.left += this.parentLeft;
to take count of the parent offset

UPDATE: ther's also a problem with large trees that need to be scrolled; in this case, there is a problem in calculating hitMode from relative cursor position because you work with clientX/clientY that doesnt care about scrolling; you have to work with pageX/pageY in line 2545 of my corrected source (see joined file):
var relPos = { x: event.pageX - nodeOfs.left, y: event.pageY - nodeOfs.top };

thanks again for dynatree
Tof 
jquery.dynatree.js.zip
23.4 KB   Download
Nov 15, 2010
Project Member #1 moo...@wwwendt.de
Another correction (by Tof):

there's also a problem with large trees that need to be scrolled; in
this case, there is a problem in calculating hitMode from relative
cursor position because you work with clientX/clientY that doesnt care
about scrolling; you have to work with pageX/pageY in line 2545 of my
corrected source (see joined file in  issue 163 ) :
var relPos = { x: event.pageX - nodeOfs.left, y: event.pageY -
nodeOfs.top }; 
Summary: drag and drop markers: offset is calced incorrectly
Status: Accepted
Owner: moo...@wwwendt.de
Labels: Milestone-Release1.0
Nov 15, 2010
Project Member #2 moo...@wwwendt.de
I commited your patch, thanks!
Summary: drag and drop markers: offset is sometimes calculated incorrectly
Status: Fixed
Nov 18, 2010
Project Member #3 moo...@wwwendt.de
Re-opened:
seems that the change has broken the drop functionality:
(It' not possible to drop *over* a node, just before)
Status: Accepted
Labels: -Priority-Medium -Milestone-Release1.0 Priority-Critical Milestone-Release1.0.1
Nov 20, 2010
Project Member #4 moo...@wwwendt.de
Fixed wíth r420
Status: Fixed
Jul 17, 2012
Project Member #5 moo...@wwwendt.de
considered verified
Jul 17, 2012
Project Member #6 moo...@wwwendt.de
(No comment was entered for this change.)
Status: Verified