1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-dd.DragZone-method-constructor'><span id='Ext-dd.DragZone'>/**
2 </span></span> * @class Ext.dd.DragZone
3 * @extends Ext.dd.DragSource
4 * <p>This class provides a container DD instance that allows dragging of multiple child source nodes.</p>
5 * <p>This class does not move the drag target nodes, but a proxy element which may contain
6 * any DOM structure you wish. The DOM element to show in the proxy is provided by either a
7 * provided implementation of {@link #getDragData}, or by registered draggables registered with {@link Ext.dd.Registry}</p>
8 * <p>If you wish to provide draggability for an arbitrary number of DOM nodes, each of which represent some
9 * application object (For example nodes in a {@link Ext.view.View DataView}) then use of this class
10 * is the most efficient way to "activate" those nodes.</p>
11 * <p>By default, this class requires that draggable child nodes are registered with {@link Ext.dd.Registry}.
12 * However a simpler way to allow a DragZone to manage any number of draggable elements is to configure
13 * the DragZone with an implementation of the {@link #getDragData} method which interrogates the passed
14 * mouse event to see if it has taken place within an element, or class of elements. This is easily done
15 * by using the event's {@link Ext.EventObject#getTarget getTarget} method to identify a node based on a
16 * {@link Ext.DomQuery} selector. For example, to make the nodes of a DataView draggable, use the following
17 * technique. Knowledge of the use of the DataView is required:</p><pre><code>
18 myDataView.on('render', function(v) {
19 myDataView.dragZone = new Ext.dd.DragZone(v.getEl(), {
21 // On receipt of a mousedown event, see if it is within a DataView node.
22 // Return a drag data object if so.
23 getDragData: function(e) {
25 // Use the DataView's own itemSelector (a mandatory property) to
26 // test if the mousedown is within one of the DataView's nodes.
27 var sourceEl = e.getTarget(v.itemSelector, 10);
29 // If the mousedown is within a DataView node, clone the node to produce
30 // a ddel element for use by the drag proxy. Also add application data
31 // to the returned data object.
33 d = sourceEl.cloneNode(true);
38 repairXY: Ext.fly(sourceEl).getXY(),
40 draggedRecord: v.{@link Ext.view.View#getRecord getRecord}(sourceEl)
45 // Provide coordinates for the proxy to slide back to on failed drag.
46 // This is the original XY coordinates of the draggable element captured
47 // in the getDragData method.
48 getRepairXY: function() {
49 return this.dragData.repairXY;
52 });</code></pre>
53 * See the {@link Ext.dd.DropZone DropZone} documentation for details about building a DropZone which
54 * cooperates with this DragZone.
56 * @param {Mixed} el The container element
57 * @param {Object} config
59 Ext.define('Ext.dd.DragZone', {
61 extend: 'Ext.dd.DragSource',
63 constructor : function(el, config){
64 this.callParent([el, config]);
65 if (this.containerScroll) {
66 Ext.dd.ScrollManager.register(this.el);
70 <span id='Ext-dd.DragZone-property-dragData'> /**
71 </span> * This property contains the data representing the dragged object. This data is set up by the implementation
72 * of the {@link #getDragData} method. It must contain a <tt>ddel</tt> property, but can contain
73 * any other data according to the application's needs.
78 <span id='Ext-dd.DragZone-cfg-containerScroll'> /**
79 </span> * @cfg {Boolean} containerScroll True to register this container with the Scrollmanager
80 * for auto scrolling during drag operations.
83 <span id='Ext-dd.DragZone-method-getDragData'> /**
84 </span> * Called when a mousedown occurs in this container. Looks in {@link Ext.dd.Registry}
85 * for a valid target to drag based on the mouse down. Override this method
86 * to provide your own lookup logic (e.g. finding a child by class name). Make sure your returned
87 * object has a "ddel" attribute (with an HTML Element) for other functions to work.
88 * @param {EventObject} e The mouse down event
89 * @return {Object} The dragData
91 getDragData : function(e){
92 return Ext.dd.Registry.getHandleFromEvent(e);
95 <span id='Ext-dd.DragZone-method-onInitDrag'> /**
96 </span> * Called once drag threshold has been reached to initialize the proxy element. By default, it clones the
98 * @param {Number} x The x position of the click on the dragged object
99 * @param {Number} y The y position of the click on the dragged object
100 * @return {Boolean} true to continue the drag, false to cancel
102 onInitDrag : function(x, y){
103 this.proxy.update(this.dragData.ddel.cloneNode(true));
104 this.onStartDrag(x, y);
108 <span id='Ext-dd.DragZone-method-afterRepair'> /**
109 </span> * Called after a repair of an invalid drop. By default, highlights this.dragData.ddel
111 afterRepair : function(){
114 Ext.fly(me.dragData.ddel).highlight(me.repairHighlightColor);
119 <span id='Ext-dd.DragZone-method-getRepairXY'> /**
120 </span> * Called before a repair of an invalid drop to get the XY to animate to. By default returns
121 * the XY of this.dragData.ddel
122 * @param {EventObject} e The mouse up event
123 * @return {Array} The xy location (e.g. [100, 200])
125 getRepairXY : function(e){
126 return Ext.core.Element.fly(this.dragData.ddel).getXY();
129 destroy : function(){
131 if (this.containerScroll) {
132 Ext.dd.ScrollManager.unregister(this.el);
136 </pre></pre></body></html>