1 if(!dojo._hasResource["dojox.gfx.Mover"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.gfx.Mover"] = true;
3 dojo.provide("dojox.gfx.Mover");
5 dojo.declare("dojox.gfx.Mover", null, {
6 constructor: function(shape, e, host){
7 // summary: an object, which makes a shape follow the mouse,
8 // used as a default mover, and as a base class for custom movers
9 // shape: dojox.gfx.Shape: a shape object to be moved
10 // e: Event: a mouse event, which started the move;
11 // only clientX and clientY properties are used
12 // host: Object?: object which implements the functionality of the move,
13 // and defines proper events (onMoveStart and onMoveStop)
15 this.lastX = e.clientX
16 this.lastY = e.clientY;
17 var h = this.host = host, d = document,
18 firstEvent = dojo.connect(d, "onmousemove", this, "onFirstMove");
20 dojo.connect(d, "onmousemove", this, "onMouseMove"),
21 dojo.connect(d, "onmouseup", this, "destroy"),
22 // cancel text selection and text dragging
23 dojo.connect(d, "ondragstart", dojo, "stopEvent"),
24 dojo.connect(d, "onselectstart", dojo, "stopEvent"),
27 // notify that the move has started
28 if(h && h.onMoveStart){
32 // mouse event processors
33 onMouseMove: function(e){
34 // summary: event processor for onmousemove
35 // e: Event: mouse event
38 this.host.onMove(this, {dx: x - this.lastX, dy: y - this.lastY});
44 onFirstMove: function(){
45 // summary: it is meant to be called only once
46 this.host.onFirstMove(this);
47 dojo.disconnect(this.events.pop());
50 // summary: stops the move, deletes all references, so the object can be garbage-collected
51 dojo.forEach(this.events, dojo.disconnect);
52 // undo global settings
54 if(h && h.onMoveStop){
58 this.events = this.shape = null;