]> git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/TimedMoveable.js.uncompressed.js
modify dojo rebuild script to remove uncompressed files
[tt-rss.git] / lib / dojo / dnd / TimedMoveable.js.uncompressed.js
1 define("dojo/dnd/TimedMoveable", ["../_base/declare", "./Moveable" /*=====, "./Mover" =====*/], function(declare, Moveable /*=====, Mover =====*/){
2 // module:
3 // dojo/dnd/TimedMoveable
4
5 /*=====
6 var __TimedMoveableArgs = declare([Moveable.__MoveableArgs], {
7 // timeout: Number
8 // delay move by this number of ms,
9 // accumulating position changes during the timeout
10 timeout: 0
11 });
12 =====*/
13
14 // precalculate long expressions
15 var oldOnMove = Moveable.prototype.onMove;
16
17 return declare("dojo.dnd.TimedMoveable", Moveable, {
18 // summary:
19 // A specialized version of Moveable to support an FPS throttling.
20 // This class puts an upper restriction on FPS, which may reduce
21 // the CPU load. The additional parameter "timeout" regulates
22 // the delay before actually moving the moveable object.
23
24 // object attributes (for markup)
25 timeout: 40, // in ms, 40ms corresponds to 25 fps
26
27 constructor: function(node, params){
28 // summary:
29 // an object that makes a node moveable with a timer
30 // node: Node||String
31 // a node (or node's id) to be moved
32 // params: __TimedMoveableArgs
33 // object with additional parameters.
34
35 // sanitize parameters
36 if(!params){ params = {}; }
37 if(params.timeout && typeof params.timeout == "number" && params.timeout >= 0){
38 this.timeout = params.timeout;
39 }
40 },
41
42 onMoveStop: function(/*Mover*/ mover){
43 if(mover._timer){
44 // stop timer
45 clearTimeout(mover._timer);
46 // reflect the last received position
47 oldOnMove.call(this, mover, mover._leftTop);
48 }
49 Moveable.prototype.onMoveStop.apply(this, arguments);
50 },
51 onMove: function(/*Mover*/ mover, /*Object*/ leftTop){
52 mover._leftTop = leftTop;
53 if(!mover._timer){
54 var _t = this; // to avoid using dojo.hitch()
55 mover._timer = setTimeout(function(){
56 // we don't have any pending requests
57 mover._timer = null;
58 // reflect the last received position
59 oldOnMove.call(_t, mover, mover._leftTop);
60 }, this.timeout);
61 }
62 }
63 });
64 });