1 define("dojo/fx/Toggler", ["../_base/lang","../_base/declare","../_base/fx", "../_base/connect"],
2 function(lang, declare, baseFx, connectUtil) {
8 return declare("dojo.fx.Toggler", null, {
10 // A simple `dojo.Animation` toggler API.
13 // class constructor for an animation toggler. It accepts a packed
14 // set of arguments about what type of animation to use in each
15 // direction, duration, etc. All available members are mixed into
16 // these animations from the constructor (for example, `node`,
17 // `showDuration`, `hideDuration`).
20 // | var t = new dojo.fx.Toggler({
22 // | showDuration: 500,
23 // | // hideDuration will default to "200"
24 // | showFunc: dojo.fx.wipeIn,
25 // | // hideFunc will default to "fadeOut"
27 // | t.show(100); // delay showing for 100ms
28 // | // ...time passes...
32 // the node to target for the showing and hiding animations
36 // The function that returns the `dojo.Animation` to show the node
37 showFunc: baseFx.fadeIn,
40 // The function that returns the `dojo.Animation` to hide the node
41 hideFunc: baseFx.fadeOut,
44 // Time in milliseconds to run the show Animation
48 // Time in milliseconds to run the hide Animation
51 // FIXME: need a policy for where the toggler should "be" the next
52 // time show/hide are called if we're stopped somewhere in the
54 // FIXME: also would be nice to specify individual showArgs/hideArgs mixed into
55 // each animation individually.
56 // FIXME: also would be nice to have events from the animations exposed/bridged
69 constructor: function(args){
74 _t._showArgs = lang.mixin({}, args);
75 _t._showArgs.node = _t.node;
76 _t._showArgs.duration = _t.showDuration;
77 _t.showAnim = _t.showFunc(_t._showArgs);
79 _t._hideArgs = lang.mixin({}, args);
80 _t._hideArgs.node = _t.node;
81 _t._hideArgs.duration = _t.hideDuration;
82 _t.hideAnim = _t.hideFunc(_t._hideArgs);
84 connectUtil.connect(_t.showAnim, "beforeBegin", lang.hitch(_t.hideAnim, "stop", true));
85 connectUtil.connect(_t.hideAnim, "beforeBegin", lang.hitch(_t.showAnim, "stop", true));
88 show: function(delay){
89 // summary: Toggle the node to showing
91 // Ammount of time to stall playing the show animation
92 return this.showAnim.play(delay || 0);
95 hide: function(delay){
96 // summary: Toggle the node to hidden
98 // Ammount of time to stall playing the hide animation
99 return this.hideAnim.play(delay || 0);