root / trunk / web / dojo / dojox / gfx / Mover.js
History | View | Annotate | Download (1.17 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.gfx.Mover"]){ |
||
9 | dojo._hasResource["dojox.gfx.Mover"]=true; |
||
10 | dojo.provide("dojox.gfx.Mover");
|
||
11 | dojo.declare("dojox.gfx.Mover",null,{constructor:function(_1,e,_2){ |
||
12 | this.shape=_1;
|
||
13 | this.lastX=e.clientX;
|
||
14 | this.lastY=e.clientY;
|
||
15 | var h=this.host=_2,d=document,_3=dojo.connect(d,"onmousemove",this,"onFirstMove"); |
||
16 | this.events=[dojo.connect(d,"onmousemove",this,"onMouseMove"),dojo.connect(d,"onmouseup",this,"destroy"),dojo.connect(d,"ondragstart",dojo,"stopEvent"),dojo.connect(d,"onselectstart",dojo,"stopEvent"),_3]; |
||
17 | if(h&&h.onMoveStart){
|
||
18 | h.onMoveStart(this);
|
||
19 | } |
||
20 | },onMouseMove:function(e){ |
||
21 | var x=e.clientX;
|
||
22 | var y=e.clientY;
|
||
23 | this.host.onMove(this,{dx:x-this.lastX,dy:y-this.lastY}); |
||
24 | this.lastX=x;
|
||
25 | this.lastY=y;
|
||
26 | dojo.stopEvent(e); |
||
27 | },onFirstMove:function(){ |
||
28 | this.host.onFirstMove(this); |
||
29 | dojo.disconnect(this.events.pop());
|
||
30 | },destroy:function(){ |
||
31 | dojo.forEach(this.events,dojo.disconnect);
|
||
32 | var h=this.host; |
||
33 | if(h&&h.onMoveStop){
|
||
34 | h.onMoveStop(this);
|
||
35 | } |
||
36 | this.events=this.shape=null; |
||
37 | }}); |
||
38 | } |