]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/dnd/TimedMoveable.js.uncompressed.js
1 define("dojo/dnd/TimedMoveable", ["../_base/declare", "./Moveable" /*=====, "./Mover" =====*/], function(declare, Moveable /*=====, Mover =====*/){
3 // dojo/dnd/TimedMoveable
6 var __TimedMoveableArgs = declare([Moveable.__MoveableArgs], {
8 // delay move by this number of ms,
9 // accumulating position changes during the timeout
14 // precalculate long expressions
15 var oldOnMove
= Moveable
.prototype.onMove
;
17 return declare("dojo.dnd.TimedMoveable", Moveable
, {
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.
24 // object attributes (for markup)
25 timeout
: 40, // in ms, 40ms corresponds to 25 fps
27 constructor: function(node
, params
){
29 // an object that makes a node moveable with a timer
31 // a node (or node's id) to be moved
32 // params: __TimedMoveableArgs
33 // object with additional parameters.
35 // sanitize parameters
36 if(!params
){ params
= {}; }
37 if(params
.timeout
&& typeof params
.timeout
== "number" && params
.timeout
>= 0){
38 this.timeout
= params
.timeout
;
42 onMoveStop: function(/*Mover*/ mover
){
45 clearTimeout(mover
._timer
);
46 // reflect the last received position
47 oldOnMove
.call(this, mover
, mover
._leftTop
);
49 Moveable
.prototype.onMoveStop
.apply(this, arguments
);
51 onMove: function(/*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
);