summaryrefslogtreecommitdiff
path: root/lib/dojo/dnd/TimedMoveable.js.uncompressed.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-18 10:26:24 +0400
committerAndrew Dolgov <[email protected]>2013-03-18 10:26:26 +0400
commitf0cfe83e3725f9a3928da97a6e3085e79cb25309 (patch)
tree4b0af188defaa807c7bc6ff3a101b41c9166c463 /lib/dojo/dnd/TimedMoveable.js.uncompressed.js
parent9a2885da170ffd64358b99194095851a2d09c1b6 (diff)
upgrade dojo to 1.8.3 (refs #570)
Diffstat (limited to 'lib/dojo/dnd/TimedMoveable.js.uncompressed.js')
-rw-r--r--lib/dojo/dnd/TimedMoveable.js.uncompressed.js64
1 files changed, 64 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..c496296fc
--- /dev/null
+++ b/lib/dojo/dnd/TimedMoveable.js.uncompressed.js
@@ -0,0 +1,64 @@
+define("dojo/dnd/TimedMoveable", ["../_base/declare", "./Moveable" /*=====, "./Mover" =====*/], function(declare, Moveable /*=====, Mover =====*/){
+ // module:
+ // dojo/dnd/TimedMoveable
+
+ /*=====
+ var __TimedMoveableArgs = declare([Moveable.__MoveableArgs], {
+ // timeout: Number
+ // delay move by this number of ms,
+ // accumulating position changes during the timeout
+ timeout: 0
+ });
+ =====*/
+
+ // precalculate long expressions
+ var oldOnMove = Moveable.prototype.onMove;
+
+ return declare("dojo.dnd.TimedMoveable", 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: __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(/*Mover*/ mover){
+ if(mover._timer){
+ // stop timer
+ clearTimeout(mover._timer);
+ // reflect the last received position
+ oldOnMove.call(this, mover, mover._leftTop);
+ }
+ Moveable.prototype.onMoveStop.apply(this, arguments);
+ },
+ onMove: function(/*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);
+ }
+ }
+ });
+});