3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 // private - DD implementation for Panels
16 Ext.define('Ext.draw.SpriteDD', {
17 extend: 'Ext.dd.DragSource',
19 constructor : function(sprite, cfg){
24 me.dragData = {el: el, sprite: sprite};
25 me.callParent([el, cfg]);
26 me.sprite.setStyle('cursor', 'move');
29 showFrame: Ext.emptyFn,
30 createFrame : Ext.emptyFn,
32 getDragEl : function(e){
36 getRegion: function() {
39 pos, x1, x2, y1, y2, t, r, b, l, bbox, sprite;
42 bbox = sprite.getBBox();
45 pos = Ext.Element.getXY(el);
55 y2 = y1 + bbox.height;
57 return Ext.create('Ext.util.Region', y1, x2, y2, x1);
61 TODO(nico): Cumulative translations in VML are handled
62 differently than in SVG. While in SVG we specify the translation
63 relative to the original x, y position attributes, in VML the translation
64 is a delta between the last position of the object (modified by the last
65 translation) and the new one.
67 In VML the translation alters the position
68 of the object, we should change that or alter the SVG impl.
71 startDrag: function(x, y) {
73 attr = me.sprite.attr;
74 me.prev = me.sprite.surface.transformToViewBox(x, y);
81 attr = sprite.attr, dx, dy;
82 xy = me.sprite.surface.transformToViewBox(xy[0], xy[1]);
83 dx = xy[0] - me.prev[0];
84 dy = xy[1] - me.prev[1];
85 sprite.setAttributes({
87 x: attr.translation.x + dx,
88 y: attr.translation.y + dy
94 setDragElPos: function () {
95 // Disable automatic DOM move in DD that spoils layout of VML engine.