]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/fx.js.uncompressed.js
12 "require" // for context sensitive loading of Toggler
13 ], function(lang
, Evented
, dojo
, arrayUtil
, connect
, baseFx
, dom
, domStyle
, geom
, ready
, require
){
18 // For back-compat, remove in 2.0.
21 var requires
= ["./fx/Toggler"];
22 require(requires
); // use indirection so modules not rolled into a build
26 var coreFx
= dojo
.fx
= {
28 // Effects library on top of Base animations
32 _fire: function(evt
, args
){
34 this[evt
].apply(this, args
||[]);
40 var _chain = function(animations
){
42 this._animations
= animations
||[];
43 this._current
= this._onAnimateCtx
= this._onEndCtx
= null;
46 arrayUtil
.forEach(this._animations
, function(a
){
47 this.duration
+= a
.duration
;
48 if(a
.delay
){ this.duration
+= a
.delay
; }
51 _chain
.prototype = new Evented();
53 _onAnimate: function(){
54 this._fire("onAnimate", arguments
);
57 connect
.disconnect(this._onAnimateCtx
);
58 connect
.disconnect(this._onEndCtx
);
59 this._onAnimateCtx
= this._onEndCtx
= null;
60 if(this._index
+ 1 == this._animations
.length
){
64 this._current
= this._animations
[++this._index
];
65 this._onAnimateCtx
= connect
.connect(this._current
, "onAnimate", this, "_onAnimate");
66 this._onEndCtx
= connect
.connect(this._current
, "onEnd", this, "_onEnd");
67 this._current
.play(0, true);
70 play: function(/*int?*/ delay
, /*Boolean?*/ gotoStart
){
71 if(!this._current
){ this._current
= this._animations
[this._index
= 0]; }
72 if(!gotoStart
&& this._current
.status() == "playing"){ return this; }
73 var beforeBegin
= connect
.connect(this._current
, "beforeBegin", this, function(){
74 this._fire("beforeBegin");
76 onBegin
= connect
.connect(this._current
, "onBegin", this, function(arg
){
77 this._fire("onBegin", arguments
);
79 onPlay
= connect
.connect(this._current
, "onPlay", this, function(arg
){
80 this._fire("onPlay", arguments
);
81 connect
.disconnect(beforeBegin
);
82 connect
.disconnect(onBegin
);
83 connect
.disconnect(onPlay
);
85 if(this._onAnimateCtx
){
86 connect
.disconnect(this._onAnimateCtx
);
88 this._onAnimateCtx
= connect
.connect(this._current
, "onAnimate", this, "_onAnimate");
90 connect
.disconnect(this._onEndCtx
);
92 this._onEndCtx
= connect
.connect(this._current
, "onEnd", this, "_onEnd");
93 this._current
.play
.apply(this._current
, arguments
);
98 var e
= connect
.connect(this._current
, "onPause", this, function(arg
){
99 this._fire("onPause", arguments
);
100 connect
.disconnect(e
);
102 this._current
.pause();
106 gotoPercent: function(/*Decimal*/percent
, /*Boolean?*/ andPlay
){
108 var offset
= this.duration
* percent
;
109 this._current
= null;
110 arrayUtil
.some(this._animations
, function(a
){
111 if(a
.duration
<= offset
){
115 offset
-= a
.duration
;
119 this._current
.gotoPercent(offset
/ this._current
.duration
, andPlay
);
123 stop: function(/*boolean?*/ gotoEnd
){
126 for(; this._index
+ 1 < this._animations
.length
; ++this._index
){
127 this._animations
[this._index
].stop(true);
129 this._current
= this._animations
[this._index
];
131 var e
= connect
.connect(this._current
, "onStop", this, function(arg
){
132 this._fire("onStop", arguments
);
133 connect
.disconnect(e
);
135 this._current
.stop();
140 return this._current
? this._current
.status() : "stopped";
143 if(this._onAnimateCtx
){ connect
.disconnect(this._onAnimateCtx
); }
144 if(this._onEndCtx
){ connect
.disconnect(this._onEndCtx
); }
147 lang
.extend(_chain
, _baseObj
);
149 coreFx
.chain = function(/*dojo/_base/fx.Animation[]*/ animations
){
151 // Chain a list of `dojo.Animation`s to run in sequence
154 // Return a `dojo.Animation` which will play all passed
155 // `dojo.Animation` instances in sequence, firing its own
156 // synthesized events simulating a single animation. (eg:
157 // onEnd of this animation means the end of the chain,
158 // not the individual animations within)
161 // Once `node` is faded out, fade in `otherNode`
163 // | dojo.fadeIn({ node:node }),
164 // | dojo.fadeOut({ node:otherNode })
167 return new _chain(animations
); // dojo/_base/fx.Animation
170 var _combine = function(animations
){
171 this._animations
= animations
||[];
176 arrayUtil
.forEach(animations
, function(a
){
177 var duration
= a
.duration
;
178 if(a
.delay
){ duration
+= a
.delay
; }
179 if(this.duration
< duration
){ this.duration
= duration
; }
180 this._connects
.push(connect
.connect(a
, "onEnd", this, "_onEnd"));
183 this._pseudoAnimation
= new baseFx
.Animation({curve
: [0, 1], duration
: this.duration
});
185 arrayUtil
.forEach(["beforeBegin", "onBegin", "onPlay", "onAnimate", "onPause", "onStop", "onEnd"],
187 self
._connects
.push(connect
.connect(self
._pseudoAnimation
, evt
,
188 function(){ self
._fire(evt
, arguments
); }
193 lang
.extend(_combine
, {
194 _doAction: function(action
, args
){
195 arrayUtil
.forEach(this._animations
, function(a
){
196 a
[action
].apply(a
, args
);
201 if(++this._finished
> this._animations
.length
){
205 _call: function(action
, args
){
206 var t
= this._pseudoAnimation
;
207 t
[action
].apply(t
, args
);
209 play: function(/*int?*/ delay
, /*Boolean?*/ gotoStart
){
211 this._doAction("play", arguments
);
212 this._call("play", arguments
);
216 this._doAction("pause", arguments
);
217 this._call("pause", arguments
);
220 gotoPercent: function(/*Decimal*/percent
, /*Boolean?*/ andPlay
){
221 var ms
= this.duration
* percent
;
222 arrayUtil
.forEach(this._animations
, function(a
){
223 a
.gotoPercent(a
.duration
< ms
? 1 : (ms
/ a
.duration
), andPlay
);
225 this._call("gotoPercent", arguments
);
228 stop: function(/*boolean?*/ gotoEnd
){
229 this._doAction("stop", arguments
);
230 this._call("stop", arguments
);
234 return this._pseudoAnimation
.status();
237 arrayUtil
.forEach(this._connects
, connect
.disconnect
);
240 lang
.extend(_combine
, _baseObj
);
242 coreFx
.combine = function(/*dojo/_base/fx.Animation[]*/ animations
){
244 // Combine a list of `dojo.Animation`s to run in parallel
247 // Combine an array of `dojo.Animation`s to run in parallel,
248 // providing a new `dojo.Animation` instance encompasing each
249 // animation, firing standard animation events.
252 // Fade out `node` while fading in `otherNode` simultaneously
254 // | dojo.fadeIn({ node:node }),
255 // | dojo.fadeOut({ node:otherNode })
259 // When the longest animation ends, execute a function:
260 // | var anim = fx.combine([
261 // | dojo.fadeIn({ node: n, duration:700 }),
262 // | dojo.fadeOut({ node: otherNode, duration: 300 })
264 // | dojo.connect(anim, "onEnd", function(){
265 // | // overall animation is done.
267 // | anim.play(); // play the animation
269 return new _combine(animations
); // dojo/_base/fx.Animation
272 coreFx
.wipeIn = function(/*Object*/ args
){
274 // Expand a node to it's natural height.
277 // Returns an animation that will expand the
278 // node defined in 'args' object from it's current height to
279 // it's natural height (with no scrollbar).
280 // Node must have no margin/border/padding.
283 // A hash-map of standard `dojo.Animation` constructor properties
284 // (such as easing: node: duration: and so on)
290 var node
= args
.node
= dom
.byId(args
.node
), s
= node
.style
, o
;
292 var anim
= baseFx
.animateProperty(lang
.mixin({
295 // wrapped in functions so we wait till the last second to query (in case value has changed)
297 // start at current [computed] height, but use 1px rather than 0
298 // because 0 causes IE to display the whole panel
300 s
.overflow
= "hidden";
301 if(s
.visibility
== "hidden" || s
.display
== "none"){
307 var height
= domStyle
.get(node
, "height");
308 return Math
.max(height
, 1);
312 return node
.scrollHeight
;
318 var fini = function(){
322 connect
.connect(anim
, "onStop", fini
);
323 connect
.connect(anim
, "onEnd", fini
);
325 return anim
; // dojo/_base/fx.Animation
328 coreFx
.wipeOut = function(/*Object*/ args
){
330 // Shrink a node to nothing and hide it.
333 // Returns an animation that will shrink node defined in "args"
334 // from it's current height to 1px, and then hide it.
337 // A hash-map of standard `dojo.Animation` constructor properties
338 // (such as easing: node: duration: and so on)
341 // | fx.wipeOut({ node:"someId" }).play()
343 var node
= args
.node
= dom
.byId(args
.node
), s
= node
.style
, o
;
345 var anim
= baseFx
.animateProperty(lang
.mixin({
348 end
: 1 // 0 causes IE to display the whole panel
353 connect
.connect(anim
, "beforeBegin", function(){
355 s
.overflow
= "hidden";
358 var fini = function(){
363 connect
.connect(anim
, "onStop", fini
);
364 connect
.connect(anim
, "onEnd", fini
);
366 return anim
; // dojo/_base/fx.Animation
369 coreFx
.slideTo = function(/*Object*/ args
){
371 // Slide a node to a new top/left position
374 // Returns an animation that will slide "node"
375 // defined in args Object from its current position to
376 // the position defined by (args.left, args.top).
379 // A hash-map of standard `dojo.Animation` constructor properties
380 // (such as easing: node: duration: and so on). Special args members
381 // are `top` and `left`, which indicate the new position to slide to.
384 // | .slideTo({ node: node, left:"40", top:"50", units:"px" }).play()
386 var node
= args
.node
= dom
.byId(args
.node
),
387 top
= null, left
= null;
389 var init
= (function(n
){
391 var cs
= domStyle
.getComputedStyle(n
);
392 var pos
= cs
.position
;
393 top
= (pos
== 'absolute' ? n
.offsetTop
: parseInt(cs
.top
) || 0);
394 left
= (pos
== 'absolute' ? n
.offsetLeft
: parseInt(cs
.left
) || 0);
395 if(pos
!= 'absolute' && pos
!= 'relative'){
396 var ret
= geom
.position(n
, true);
399 n
.style
.position
="absolute";
400 n
.style
.top
=top
+"px";
401 n
.style
.left
=left
+"px";
407 var anim
= baseFx
.animateProperty(lang
.mixin({
413 connect
.connect(anim
, "beforeBegin", anim
, init
);
415 return anim
; // dojo/_base/fx.Animation