3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
9
Ext.dd.DragTracker = function(config){
10
Ext.apply(this, config);
20
this.dragRegion = new Ext.lib.Region(0,0,0,0);
27
Ext.extend(Ext.dd.DragTracker, Ext.util.Observable, {
33
this.el = Ext.get(el);
34
el.on('mousedown', this.onMouseDown, this,
35
this.delegate ? {delegate: this.delegate} : undefined);
39
this.el.un('mousedown', this.onMouseDown, this);
42
onMouseDown: function(e, target){
43
if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
44
this.startXY = this.lastXY = e.getXY();
45
this.dragTarget = this.delegate ? target : this.el.dom;
47
var doc = Ext.getDoc();
48
doc.on('mouseup', this.onMouseUp, this);
49
doc.on('mousemove', this.onMouseMove, this);
50
doc.on('selectstart', this.stopSelect, this);
52
this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
57
onMouseMove: function(e, target){
59
var xy = e.getXY(), s = this.startXY;
62
if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
68
this.fireEvent('mousemove', this, e);
70
this.fireEvent('drag', this, e);
73
onMouseUp: function(e){
74
var doc = Ext.getDoc();
75
doc.un('mousemove', this.onMouseMove, this);
76
doc.un('mouseup', this.onMouseUp, this);
77
doc.un('selectstart', this.stopSelect, this);
82
this.fireEvent('mouseup', this, e);
84
this.fireEvent('dragend', this, e);
87
triggerStart: function(isTimer){
90
this.onStart(this.startXY);
91
this.fireEvent('dragstart', this, this.startXY);
94
clearStart : function(){
96
clearTimeout(this.timer);
101
stopSelect : function(e){
106
onBeforeStart : function(e){
110
onStart : function(xy){
114
onDrag : function(e){
122
getDragTarget : function(){
123
return this.dragTarget;
126
getDragCt : function(){
130
getXY : function(constrain){
132
this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
135
getOffset : function(constrain){
136
var xy = this.getXY(constrain);
137
var s = this.startXY;
138
return [s[0]-xy[0], s[1]-xy[1]];
142
'point' : function(xy){
145
this.elRegion = this.getDragCt().getRegion();
148
var dr = this.dragRegion;
155
dr.constrainTo(this.elRegion);
157
return [dr.left, dr.top];
b'\\ No newline at end of file'