<!DOCTYPE html>
|
<html>
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>The source code</title>
|
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
|
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
|
<style type="text/css">
|
.highlight { display: block; background-color: #ddd; }
|
</style>
|
<script type="text/javascript">
|
function highlight() {
|
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
|
}
|
</script>
|
</head>
|
<body onload="prettyPrint(); highlight();">
|
<pre class="prettyprint lang-js"><span id='Ext-draw-SpriteDD'>/**
|
</span> * DD implementation for Panels.
|
* @private
|
*/
|
Ext.define('Ext.draw.SpriteDD', {
|
extend: 'Ext.dd.DragSource',
|
|
<span id='Ext-draw-SpriteDD-method-constructor'> constructor : function(sprite, cfg){
|
</span> var me = this,
|
el = sprite.el;
|
me.sprite = sprite;
|
me.el = el;
|
me.dragData = {el: el, sprite: sprite};
|
me.callParent([el, cfg]);
|
me.sprite.setStyle('cursor', 'move');
|
},
|
|
<span id='Ext-draw-SpriteDD-method-showFrame'> showFrame: Ext.emptyFn,
|
</span><span id='Ext-draw-SpriteDD-method-createFrame'> createFrame : Ext.emptyFn,
|
</span>
|
<span id='Ext-draw-SpriteDD-method-getDragEl'> getDragEl : function(e){
|
</span> return this.el;
|
},
|
|
<span id='Ext-draw-SpriteDD-method-getRegion'> getRegion: function() {
|
</span> var me = this,
|
el = me.el,
|
pos, x1, x2, y1, y2, t, r, b, l, bbox, sprite;
|
|
sprite = me.sprite;
|
bbox = sprite.getBBox();
|
|
try {
|
pos = Ext.Element.getXY(el);
|
} catch (e) { }
|
|
if (!pos) {
|
return null;
|
}
|
|
x1 = pos[0];
|
x2 = x1 + bbox.width;
|
y1 = pos[1];
|
y2 = y1 + bbox.height;
|
|
return new Ext.util.Region(y1, x2, y2, x1);
|
},
|
|
<span id='Ext-draw-SpriteDD-method-startDrag'> /*
|
</span> TODO(nico): Cumulative translations in VML are handled
|
differently than in SVG. While in SVG we specify the translation
|
relative to the original x, y position attributes, in VML the translation
|
is a delta between the last position of the object (modified by the last
|
translation) and the new one.
|
|
In VML the translation alters the position
|
of the object, we should change that or alter the SVG impl.
|
*/
|
|
startDrag: function(x, y) {
|
var me = this,
|
attr = me.sprite.attr;
|
me.prev = me.sprite.surface.transformToViewBox(x, y);
|
},
|
|
<span id='Ext-draw-SpriteDD-method-onDrag'> onDrag: function(e) {
|
</span> var xy = e.getXY(),
|
me = this,
|
sprite = me.sprite,
|
attr = sprite.attr, dx, dy;
|
xy = me.sprite.surface.transformToViewBox(xy[0], xy[1]);
|
dx = xy[0] - me.prev[0];
|
dy = xy[1] - me.prev[1];
|
sprite.setAttributes({
|
translate: {
|
x: attr.translation.x + dx,
|
y: attr.translation.y + dy
|
}
|
}, true);
|
me.prev = xy;
|
},
|
|
<span id='Ext-draw-SpriteDD-method-setDragElPos'> setDragElPos: function () {
|
</span> // Disable automatic DOM move in DD that spoils layout of VML engine.
|
return false;
|
}
|
});</pre>
|
</body>
|
</html>
|