1 if(!dojo._hasResource["dojo.dnd.TimedMoveable"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojo.dnd.TimedMoveable"] = true;
3 dojo.provide("dojo.dnd.TimedMoveable");
5 dojo.require("dojo.dnd.Moveable");
8 // precalculate long expressions
9 var oldOnMove = dojo.dnd.Moveable.prototype.onMove;
11 dojo.declare("dojo.dnd.TimedMoveable", dojo.dnd.Moveable, {
13 // A specialized version of Moveable to support an FPS throttling.
14 // This class puts an upper restriction on FPS, which may reduce
15 // the CPU load. The additional parameter "timeout" regulates
16 // the delay before actually moving the moveable object.
18 // object attributes (for markup)
19 timeout: 40, // in ms, 40ms corresponds to 25 fps
21 constructor: function(node, params){
22 // summary: an object, which makes a node moveable with a timer
23 // node: Node: a node (or node's id) to be moved
24 // params: Object: an optional object with additional parameters.
25 // See dojo.dnd.Moveable for details on general parameters.
26 // Following parameters are specific for this class:
27 // timeout: Number: delay move by this number of ms
28 // accumulating position changes during the timeout
30 // sanitize parameters
31 if(!params){ params = {}; }
32 if(params.timeout && typeof params.timeout == "number" && params.timeout >= 0){
33 this.timeout = params.timeout;
38 markupFactory: function(params, node){
39 return new dojo.dnd.TimedMoveable(node, params);
42 onMoveStop: function(/* dojo.dnd.Mover */ mover){
45 clearTimeout(mover._timer)
46 // reflect the last received position
47 oldOnMove.call(this, mover, mover._leftTop)
49 dojo.dnd.Moveable.prototype.onMoveStop.apply(this, arguments);
51 onMove: function(/* dojo.dnd.Mover */ mover, /* Object */ leftTop){
52 mover._leftTop = leftTop;
54 var _t = this; // to avoid using dojo.hitch()
55 mover._timer = setTimeout(function(){
56 // we don't have any pending requests
58 // reflect the last received position
59 oldOnMove.call(_t, mover, mover._leftTop);