-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
225 lines (216 loc) · 5.87 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="./lib/Schwifty.min.js"></script>
<script type="text/javascript" src="https://rawgithub.com/Autarc/optimal-select/master/dist/optimal-select.min.js"></script>
<style type="text/css">
body,
html {
height: 100%;
margin: 0;
background: #fff;
}
div {
padding: 10px;
background: #eee;
margin: 5px;
width: 120px;
height: 80px;
border-radius: 3px;
border: 1px dashed #ccc;
display: inline-block;
}
aside {
margin: 10px;
padding: 5px;
border: 1px solid #ccc;
}
.mult {
position: relative;
}
.offset {
left: 20px;
}
aside.bound {
height: 120px;
}
.cont {
background: #ccc;
height: 0;
overflow: hidden;
}
</style>
<title>schwifty - css animation framework by mityok</title>
</head>
<body>
<aside> <button class="btn1">Basic staggerTo</button>
<div class="aaa schwifty-mine-1">1</div>
<div class="aaa schwifty-mine-2">2</div>
<div class="aaa schwifty-mine-3">3</div>
<div class="aaa schwifty-mine-3a">3</div>
<div class="aaa schwifty-mine-3b">3</div>
</aside>
<aside> <button class="btn2">Change Animation to</button>
<div class="bbb schwifty-mine-4">1</div>
</aside>
<aside> <button class="btn3">Multi-value staggerTo</button>
<div class="ccc schwifty-mine-5">1</div>
<div class="ccc schwifty-mine-6">2</div>
<div class="ccc schwifty-mine-7">3</div>
</aside>
<aside> <button class="btn8">Height 0 to auto</button>
<main class="hhh cont schwifty-mine-12">
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
</main>
</aside>
<aside> <button class="btn4">Set Position</button>
<div class="ddd schwifty-mine-8">1</div>
</aside>
<aside> <button class="btn5">Multiple properties from to</button>
<div class="eee mult schwifty-mine-9">1</div>
</aside>
<aside class="bound"> <button class="btn6">Elastic to</button>
<div class="fff mult offset schwifty-mine-10">1</div>
</aside>
<aside> <button class="btn7">Elastic fromTo</button>
<div class="ggg mult schwifty-mine-11">1</div>
</aside>
<script>
//body update
//Schwifty.bodyClassUpdate(true,'.getting-schwifty {overflow: hidden;background:#f8f8f8;}');
//Basic stagger:
var aaa = document.querySelectorAll('.aaa');
document.querySelector('.btn1').addEventListener('click', () => {
Schwifty.staggerTo(aaa, 2, {
x: '50%',
y: 60,
onComplete: (an) => {
console.log('comp')
},
ease: 'cubic-bezier(0.42, 0, 0.58, 1)',
fix: 'style',
delay:1,
}, null, 0.3);
});
//Multi-value stagger:
var ccc = document.querySelectorAll('.ccc');
document.querySelector('.btn3').addEventListener('click', () => {
Schwifty.staggerTo(ccc, 1, {
x: ['50%', 10, '10em'],
y: [20, 40, 60],
backgroundColor:['red','green','blue'],
opacity:[0.8,0.2,0.5],
important: ['transform'],
onComplete: (an) => {
console.log('comp 3')
},
fix: 'style'
}, null, 0.1);
});
//Change Animation:
var bbb = document.querySelector('.bbb');
document.querySelector('.btn2').addEventListener('click', () => {
Schwifty.to(bbb, 4, {
opacity: 1,
x: '200%',
y: 100,
scale: .5,
rotate: 90,
important: ['opacity'],
fix: 'style',
onComplete: () => {
console.log('bbb end')
}
});
setTimeout(() => {
Schwifty.to(bbb, 4, {
x: 200,
fix: 'style',
onComplete: () => {
console.log('done')
}
});
}, 2000)
});
//Set position:
var ddd = document.querySelector('.ddd');
document.querySelector('.btn4').addEventListener('click', () => {
Schwifty.set(ddd, {
opacity: Math.random(),
x: `${Math.ceil(Math.random()*200)}%`,
rotate: Math.ceil(Math.random() * 90)
});
});
///Multiple properties from to
var eee = document.querySelector('.eee');
document.querySelector('.btn5').addEventListener('click', () => {
Schwifty.fromTo(eee, 5, {
left: 0,
top: 0,
color: 'red',
backgroundColor: 'yellow'
}, {
left: 200,
top: 50,
color: '#0f0',
backgroundColor: '#ccc',
fix: 'style',
delay: 2
});
});
//Elastic
var fff = document.querySelector('.fff');
document.querySelector('.btn6').addEventListener('click', () => {
Schwifty.to(fff, 1, {
left: Math.floor(Math.random() * 400),
top: `${Math.floor(Math.random()*100)}%`,
fix: 'style',
ease: 'easeOutElastic',
delay: 0,
important: ['left', 'top']
});
});
//Elastic fromTo
var ggg = document.querySelector('.ggg');
document.querySelector('.btn7').addEventListener('click', () => {
Schwifty.fromTo(ggg, 1, {
left: `${50}%`,
top: '4pt'
}, {
left: `${10}px`,
top: 100,
fix: 'style',
ease: 'easeOutElastic',
delay: 0,
important: ['left', 'top']
});
});
//Height 0 to auto
var hhh = document.querySelector('.hhh');
document.querySelector('.btn8').addEventListener('click', () => {
Schwifty.to(hhh, 1, {
height: 'auto',
immediateRender: true,
fix: 'style',
ease: 'easeOutElastic',
important: ['height']
});
});
</script>
</body>
</html>