This repository has been archived by the owner on May 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
/
advance-animation.html
206 lines (178 loc) · 5.95 KB
/
advance-animation.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
<!DOCTYPE html>
<html>
<head>
<meta charSet="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Minigrid advance animation example</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<style type="text/css">
.cards {
margin: auto; /* center grid */
}
.card {
width: 200px;
overflow: hidden;
opacity: 0; /* hide card while loading */
transform-property: opacity, transform;
transform-origin: 50%;
}
/* change card size for small screens */
@media (max-width: 600px) {
.card { width: 156px; }
}
</style>
</head>
<body>
<div class="demo">
<div class="cards">
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/2a/30/13/2a3013448eb806e51da5de96eb38cf36.jpg" />
</div>
<div class="card-info">
Villetta Barrea and Scanno, Abruzzo, Italy
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/fa/a2/41/faa24120c4689443e2169366972cb194.jpg" />
</div>
<div class="card-info">
Vøringfossen, Norway
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/f9/06/4c/f9064c91a4f63705e5a4408cda6739de.jpg" />
</div>
<div class="card-info">
Theogefiro, Zitsa, Greece
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/ab/e2/1b/abe21b2f3a5be204cb2436d0b9cc6a1d.jpg" />
</div>
<div class="card-info">
Los Andes, Argentina
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/7f/20/c5/7f20c589a41bffc8c0b8960fc8001160.jpg" />
</div>
<div class="card-info">
Moon Mountain, Yangshuo, Guangxi, China
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/54/a0/e0/54a0e0acf60f33f9b64528bd364ce5d6.jpg" />
</div>
<div class="card-info">
Valley of the Ten Peaks, Moraine Lake, Canada
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/d2/d5/aa/d2d5aa40108038f92d4cb0edca78ec26.jpg" />
</div>
<div class="card-info">
Hawaii
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/f7/e2/c0/f7e2c018f5ec39a83df831495ed9cad5.jpg" />
</div>
<div class="card-info">
Chichimilá, Yucatan, Mexico
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/a7/51/a9/a751a9a163c76ea37eba4747c35d1940.jpg" />
</div>
<div class="card-info">
Basalt Pinnacles, Scotland
</div>
</div>
</div>
<div class="card">
<div class="card-wrapper">
<div class="card-image">
<img src="https://s-media-cache-ak0.pinimg.com/236x/d9/86/6b/d9866b911c08387bc8ab17a6c9897e85.jpg" />
</div>
<div class="card-info">
Somewhere, Iceland
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
<script src="../src/index.js"></script>
<script>
(function(){
function grid(isWindowResizing) {
minigrid({
container: '.cards',
item: '.card',
gutter: 6,
animate: function(el, x, y, index) {
// set a different delay value for each item to make sure they don't show
// all in the same time
var delay = 100 + index * 30;
var initialDelay = isWindowResizing ? 0 : 500;
// first lets set the item position without animate it
Velocity(el, {
translateX: x + 'px',
translateY: y + 'px',
translateZ: 0
}, {
duration: 0,
delay: initialDelay,
complete: function() {
// if the window is resizing just set the item position and return
if (isWindowResizing) {
return;
}
// now we can animate, in this case the opacity and scale
Velocity(el, {
opacity: [1, 0],
scale: [1, 0.9],
}, {
duration: 300,
easing: [.4,.2,.5,1.4],
delay: delay
});
}
});
}
});
}
window.addEventListener('resize', function(){
grid(true);
});
grid();
})();
</script>
</body>
</html>