| 1 |
define(["dojo/_base/declare", "dijit/_Widget", "dojo/_base/html", "dojo/dom-style"], |
| 2 |
function(declare, Widget, htmlUtil, domStyle){ |
| 3 |
return declare("dojox.layout.DragPane", Widget, { |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
invert: true, |
| 16 |
|
| 17 |
postCreate: function(){ |
| 18 |
this.connect(this.domNode, "onmousedown", "_down"); |
| 19 |
this.connect(this.domNode, "onmouseleave", "_up"); |
| 20 |
this.connect(this.domNode, "onmouseup", "_up"); |
| 21 |
}, |
| 22 |
|
| 23 |
_down: function( e){ |
| 24 |
|
| 25 |
|
| 26 |
var t = this.domNode; |
| 27 |
e.preventDefault(); |
| 28 |
domStyle.set(t, "cursor", "move"); |
| 29 |
this._x = e.pageX; |
| 30 |
this._y = e.pageY; |
| 31 |
if ((this._x < t.offsetLeft + t.clientWidth) && |
| 32 |
(this._y < t.offsetTop + t.clientHeight)) { |
| 33 |
htmlUtil.setSelectable(t,false); |
| 34 |
this._mover = this.connect(t, "onmousemove", "_move"); |
| 35 |
} |
| 36 |
}, |
| 37 |
|
| 38 |
_up: function( e){ |
| 39 |
|
| 40 |
|
| 41 |
htmlUtil.setSelectable(this.domNode,true); |
| 42 |
domStyle.set(this.domNode, "cursor", "pointer"); |
| 43 |
this._mover && this.disconnect(this._mover); |
| 44 |
delete this._mover; |
| 45 |
}, |
| 46 |
|
| 47 |
_move: function( e){ |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
var mod = this.invert ? 1 : -1; |
| 53 |
this.domNode.scrollTop += (this._y - e.pageY) * mod; |
| 54 |
this.domNode.scrollLeft += (this._x - e.pageX) * mod; |
| 55 |
this._x = e.pageX; |
| 56 |
this._y = e.pageY; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
}); |
| 61 |
}); |