diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:10 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 18:59:18 +0400 |
commit | 1354d17270961fff662d40f90521223f8fd0d73b (patch) | |
tree | e9266be71587e47c800303446e968a6d3565e2cf /lib/dojo/dnd/TimedMoveable.js.uncompressed.js | |
parent | d04f8c826f5283765f52cf6b98b42a1ed8f2d6bc (diff) |
update dojo to 1.7.3
Diffstat (limited to 'lib/dojo/dnd/TimedMoveable.js.uncompressed.js')
-rw-r--r-- | lib/dojo/dnd/TimedMoveable.js.uncompressed.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/dojo/dnd/TimedMoveable.js.uncompressed.js b/lib/dojo/dnd/TimedMoveable.js.uncompressed.js new file mode 100644 index 000000000..66bcdd2e3 --- /dev/null +++ b/lib/dojo/dnd/TimedMoveable.js.uncompressed.js @@ -0,0 +1,69 @@ +define("dojo/dnd/TimedMoveable", ["../main", "./Moveable"], function(dojo) { + // module: + // dojo/dnd/TimedMoveable + // summary: + // TODOC + + /*===== + dojo.declare("dojo.dnd.__TimedMoveableArgs", [dojo.dnd.__MoveableArgs], { + // timeout: Number + // delay move by this number of ms, + // accumulating position changes during the timeout + timeout: 0 + }); + =====*/ + + // precalculate long expressions + var oldOnMove = dojo.dnd.Moveable.prototype.onMove; + + dojo.declare("dojo.dnd.TimedMoveable", dojo.dnd.Moveable, { + // summary: + // A specialized version of Moveable to support an FPS throttling. + // This class puts an upper restriction on FPS, which may reduce + // the CPU load. The additional parameter "timeout" regulates + // the delay before actually moving the moveable object. + + // object attributes (for markup) + timeout: 40, // in ms, 40ms corresponds to 25 fps + + constructor: function(node, params){ + // summary: + // an object that makes a node moveable with a timer + // node: Node||String + // a node (or node's id) to be moved + // params: dojo.dnd.__TimedMoveableArgs + // object with additional parameters. + + // sanitize parameters + if(!params){ params = {}; } + if(params.timeout && typeof params.timeout == "number" && params.timeout >= 0){ + this.timeout = params.timeout; + } + }, + + onMoveStop: function(/* dojo.dnd.Mover */ mover){ + if(mover._timer){ + // stop timer + clearTimeout(mover._timer); + // reflect the last received position + oldOnMove.call(this, mover, mover._leftTop) + } + dojo.dnd.Moveable.prototype.onMoveStop.apply(this, arguments); + }, + onMove: function(/* dojo.dnd.Mover */ mover, /* Object */ leftTop){ + mover._leftTop = leftTop; + if(!mover._timer){ + var _t = this; // to avoid using dojo.hitch() + mover._timer = setTimeout(function(){ + // we don't have any pending requests + mover._timer = null; + // reflect the last received position + oldOnMove.call(_t, mover, mover._leftTop); + }, this.timeout); + } + } + }); + + return dojo.dnd.TimedMoveable; + +}); |