1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>dojox.layout.SizingPane</title>
<script type="text/javascript" src="../../../dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dijit.dijit");
dojo.require("dojo.fx");
</script>
<style type="text/css">
@import "../../../dojo/resources/dojo.css";
@import "../../../dijit/themes/dijit.css";
@import "../../../dijit/themes/tundra/tundra.css";
@import "../../../dijit/tests/css/dijitTests.css";
body { background:#ededed; color:#666; }
#nav {
position:absolute;
top:100px;
left:10px;
width:200px;
-moz-border-radius:8pt 8pt;
background:#fff;
border:2px solid #ccc;
}
#box1 {
overflow:hidden;
position:absolute;
display:block;
width:25px;
height:25px;
-moz-border-radius:8pt 8pt;
radius:8pt;
-webkit-border-radius:8pt 8pt;
background:#fff;
border:2px solid #ccc;
padding:7px;
}
</style>
<script>
var animationMethod = "chain"; // || combine
var _showing = false;
var animG, offsetW, offsetH = null;
var box1 = null;
var boxMixin = {
startWidth: 25,
startHeight: 25,
endWidth: 320,
endHeight: 320,
duration: 300
};
dojo.addOnLoad(function() {
box1 = dojo.byId('box1');
centerNode(box1);
dojo.connect(box1,"onmouseover",null,"show");
dojo.connect(box1,"onmouseout",null,"hideCheck");
//dojo.connect(box1,"onmouseout",null,"hideCheck");
//dojo.connect(but1,"onclick",null,"show");
});
function hideCheck(node) {
if (_showing) {
setTimeout(function(){hide('box1');},125);
}
}
function centerNode(node) {
var viewport = dijit.getViewport();
var mb = dojo.marginBox(node);
var style = node.style;
offsetW = mb.w - style.width;
offsetH = mb.h - style.height;
style.left = (viewport.l + (viewport.w - mb.w)/2) + "px";
style.top = (viewport.t + (viewport.h - mb.h)/2) + "px";
}
function doUnderlay() {
console.debug('make underlay');
}
function show() {
if (_showing) { return; }
if (animG && animG.status == "playing") { animG.stop(); }
_showing = true;
var viewport = dijit.getViewport();
var newLeft = (viewport.l + (viewport.w - boxMixin.endWidth)/2);
var newTop = (viewport.t + (viewport.h - boxMixin.endHeight)/2);
var style = box1.style;
var anim1 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
width: { /* start: boxMixin.startWidth, */ end: boxMixin.endWidth, unit:"px" },
left: { end: newLeft, unit:"px" }
},
beforeBegin: doUnderlay()
});
var anim2 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
height: { /*start: boxMixin.startHeight, */ end: boxMixin.endHeight, unit:"px" },
top: { end: newTop, unit: "px" }
},
onEnd: function() { _showing = true; }
});
animG = dojo.fx[animationMethod]([anim1,anim2]).play();
// chain:
// animate width / left position
// animate height / top position
// onend: fadeIn content?
}
function hide(node) {
if (!_showing) return;
if (animG && animG.status() == "playing") { animG.stop(); }
var viewport = dijit.getViewport();
var newLeft = (viewport.l + (viewport.w - boxMixin.startWidth)/2);
var newTop = (viewport.t + (viewport.h - boxMixin.startHeight)/2);
var style = node.style;
var anim1 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
width: { end: boxMixin.startWidth, unit:"px" },
left: { end: newLeft, unit:"px" }
}
});
var anim2 = dojo.animateProperty({
node: box1,
duration: boxMixin.duration/2,
properties: {
height: { end: boxMixin.startHeight, unit:"px" },
top: { end: newTop, unit: "px" }
},
onEnd: function() { _showing = false; }
});
// if we chain, do anim2 first [because height/top is how anim2 in show() ends]
animG = dojo.fx[animationMethod]([anim2,anim1]).play();
}
</script>
</head>
<body class="tundra">
<h1 class="testTitle">dojox.layout.SizingPane</h1>
<p>This is simply a test / example. There is no <i>real</i> dojox.layout.SizingPane, but this code
should/might become part of a dojox.fx.toggle class ... it's just "neat", isn't it?</p>
<div id="box1">
lorem. lorem. lorem.
</div>
</body>
</html>
|