View Full Version : [OPEN] DragZone's contrainTo method does not work as expected

20 Jun 2007, 11:39 AM
If you create a DragZone in a document with:

<div id="constraint" style="width: 650px; height: 350px;">[Organizer Layout]</div>

and then call:


The Proxy element will get constrained to something completely inconsistent with the dimensions of the "constraint" element.

For an example, please see an implementation of the Ext Tutorial's Image Organizer with constraints added:


When you drag the image thumbnail, the proxy element gets locked into a box approximately 318px wide and 103px tall. It should appear to be constrained to the dimensions of the Layout element.

Overall, I think there are quite a few flaws lurking within DragZone (and maybe some other DD elements as well). The code just doesn't seem to be quite as well formatted and thought out as the rest of the framework. For example, sometimes "this.el" is used whereas other methods use the local getEl() method. One method even assigns the results of a getEl call to a local "el" variable and then never uses that variable anywhere in the method (showFrame method, DDCore.js, line 2854.)

See my post here http://extjs.com/forum/showthread.php?t=7993 for more information.

Unless you are using a widget (like Tree or Grid) that has built-in DD support, getting the DD stuff to work on its own is very difficult and frustrating. Since there seem to be several posts of very confused users with very little resolution, I think some more time needs to be spent on fleshing out the DD support and maybe even a few tutorials written. I have spent 3 days going over this DragZone stuff and I'm still completely baffled as to how it all works .

20 Jun 2007, 5:56 PM
The base DDCore.js code is a direct port from the YUI DD code. Unfortunately, that means it is not as consistent with standard Ext code.

As for you constrainTo problem, constraints must be applied before every drag starts (see the examples in the constrainTo docs). However, it will never work a DragZone as a DragZone uses delegation with one primary element. The dimensions of that primary element will always be used for the constraining. In your case, that would be the entire View.

21 Jun 2007, 9:11 AM
Its a shame that constrainTo can't work with a DragZone, et al. It would certainly be nice if that support could be added in the future. Until then, it should probably be removed from the constructor. Or the docs should at least mention which inheirited methods are not supported.