-
Notifications
You must be signed in to change notification settings - Fork 57
/
examples.html
283 lines (269 loc) · 8.11 KB
/
examples.html
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<!DOCTYPE HTML>
<html lang="en-us">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Morpheus Examples</title>
<style type="text/css" media="screen">
body {
font: 300 13px helvetica neue;
}
button {
padding: 7px;
width: 50px;
cursor: pointer;
}
h1,h2 {
font-weight: 300;
margin: 0;
padding: 0;
}
h1 {
font-size: 36px;
}
#doc {
width: 550px;
margin: 0 auto;
}
.stage {
padding: 50px;
background: #eee;
border-radius: 10px;
border: 1px solid #bbb;
margin: 15px 0;
position: relative;
overflow: hidden;
}
.box {
top: 0;
left: 0;
position: relative;
width: 20px;
height: 20px;
border-radius: 4px;
background: #f00;
margin: 5px 0;
border: 1px solid #999;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
#last {
margin-bottom: 100px;
}
</style>
<script src="src/morpheus.js" type="text/javascript"></script>
<script src="src/easings.js" type="text/javascript"></script>
<script src="integration/ender.js" type="text/javascript"></script>
<script type="text/javascript">
function id(el) {
return document.getElementById(el)
}
</script>
</head>
<body>
<div id="doc">
<h1>Morpheus Examples</h1>
<div class="stage">
<h2>General</h2>
<div id="ex1" class="box"></div>
<button id="go-ex1">Go</button>
<script type="text/javascript">
id('go-ex1').onclick = function () {
id('go-ex1').disabled = true
id('ex1').style.left = 0
morpheus(id('ex1'), {
left: 400,
complete: function () {
id('go-ex1').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>Color</h2>
<div id="ex3" class="box"></div>
<button id="go-ex3">Go</button>
<script type="text/javascript">
id('go-ex3').onclick = function () {
id('go-ex3').disabled = true
id('ex3').style.backgroundColor = '#f00'
morpheus(id('ex3'), {
backgroundColor: '#00f',
duration: 2000,
complete: function () {
id('go-ex3').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>Motion + Color</h2>
<div id="ex2" class="box"></div>
<button id="go-ex2">Go</button>
<script type="text/javascript">
id('go-ex2').onclick = function () {
id('go-ex2').disabled = true
id('ex2').style.left = 0
id('ex2').style.backgroundColor = '#f00'
id('ex2').style.width = '20px'
morpheus(id('ex2'), {
left: 400,
width: '+=20',
backgroundColor: '#00f',
easing: easings.bounce,
complete: function () {
id('go-ex2').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>Alternative units</h2>
<div id="ex4" style="font-size: 1.2em;left: 200px;position: absolute;">hello world</div>
<button id="go-ex4">Go</button>
<script type="text/javascript">
id('go-ex4').onclick = function () {
id('go-ex4').disabled = true
id('ex4').style.fontSize = '1.2em'
morpheus(id('ex4'), {
fontSize: '+=3.1em',
easing: easings.spring,
complete: function () {
id('go-ex4').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>Bezier Curves</h2>
<div id="ex5" class="box"></div>
<button id="go-ex5">Go</button>
<script type="text/javascript">
id('go-ex5').onclick = function () {
id('go-ex5').disabled = true
id('ex5').style.left = 0
morpheus(id('ex5'), {
duration: 2000,
easing: easings.easeIn,
left: 400,
bezier: [[150, 300], [300, -300]],
complete: function () {
id('go-ex5').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>Multiple elements</h2>
<div id="ex6">
<div data-to="#0f0" class="box"></div>
<div data-to="#00c" class="box"></div>
</div>
<button id="go-ex6">Go</button>
<script type="text/javascript">
function rand(n) {
var poz = [' ', '-']
var prefix = poz[Math.floor(Math.random() * 2)]
var r = parseInt(prefix + Math.floor(Math.random() * n), 10)
return r;
}
id('go-ex6').onclick = function () {
id('go-ex6').disabled = true
$('#ex6 .box').css({
left: 1,
top: 0,
width: 20,
backgroundColor: '#f00'
})
morpheus(id('ex6').getElementsByTagName('div'), {
duration: 3000,
easing: easings.swingTo,
left: function () {
return '+=' + Math.abs(rand(400))
},
width: '+=80',
backgroundColor: function (el) {
return el.getAttribute('data-to')
},
bezier: function (el) {
return [[rand(300), rand(300)], [rand(300), rand(300)]]
},
complete: function () {
id('go-ex6').disabled = false
}
})
}
</script>
</div>
<div class="stage">
<h2>stopping animations</h2>
<div style="width:100px;height:100px;" id="ex7" class="box"></div>
<script type="text/javascript">
!function () {
var anim = {
stop: function () {}
}
id('ex7').onclick = function () {
anim.stop(true);
};
id('ex7').onmouseover = function () {
anim.stop();
anim = morpheus(id('ex7'), {
backgroundColor: '#00f',
width: 400
})
};
id('ex7').onmouseout = function () {
anim.stop();
anim = morpheus(id('ex7'), {
backgroundColor: '#f00',
width: 100
})
};
}();
</script>
</div>
<div class="stage" id="last">
<h2>Transform</h2>
<div id="ex8-scale" class="box">scale</div>
<div id="ex8-rotate" class="box">rotate</div>
<div id="ex8-skew" class="box">skew</div>
<div id="ex8-translate" class="box">translate</div>
<button id="go-ex8">Go</button>
<button id="reset-ex8">Reset</button>
<script type="text/javascript">
function reset() {
id('ex8-rotate').style[morpheus.transform] = 'rotate(0deg)'
id('ex8-scale').style[morpheus.transform] = 'scale(1)'
id('ex8-skew').style[morpheus.transform] = 'skew(0deg, 0deg)'
id('ex8-translate').style[morpheus.transform] = 'translate(0px,0px)'
}
reset()
id('reset-ex8').onclick = reset
id('go-ex8').onclick = function () {
id('go-ex8').disabled = true
morpheus(id('ex8-rotate'), {
transform: 'rotate(+=70deg)'
})
morpheus(id('ex8-scale'), {
transform: 'scale(+=1)'
})
morpheus(id('ex8-skew'), {
transform: 'skew(10deg,+=10deg)'
})
morpheus(id('ex8-translate'), {
transform: 'translate(+=50px,+=25px)',
complete: function () {
id('go-ex8').disabled = false
}
})
}
</script>
</div>
</div>
</body>
</html>