-
Notifications
You must be signed in to change notification settings - Fork 145
/
index.html
497 lines (475 loc) · 13.3 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
<!DOCTYPE html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>cta.js - Animate your 'action-to-effect' paths!</title>
<meta name="author" content="Kushagra Gour" />
<meta
name="description"
content="Animate any element onto another element."
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="image_src" href="hint.png" />
<link
href="http://fonts.googleapis.com/css?family=Open+Sans:400,300"
rel="stylesheet"
type="text/css"
/>
<style>
* {
box-sizing: border-box;
}
html,
body {
font-family: "Open Sans", sans-serif;
background: #3f51b5;
color: white;
text-align: center;
margin: 0;
font-size: 18px;
}
p,
.content-wrap {
max-width: 770px;
margin: 0 auto;
}
p {
font-size: 24px;
margin: 0 auto 30px;
padding: 0 40px;
}
h1,
h2 {
font-weight: bold;
}
h2 {
font-size: 40px;
}
a {
color: #ffd200;
}
a:hover {
text-decoration: none;
}
section {
padding: 30px 0;
}
.section--white {
background: white;
color: #555;
}
.disable-mouse {
pointer-events: none;
}
body.disable-scroll {
overflow: hidden;
height: 100%;
}
.main-title {
color: white;
font-size: 100px;
}
.btn,
.tile {
display: inline-block;
text-decoration: none;
padding: 16px;
background: #ea006f;
color: white;
opacity: 0.85;
cursor: pointer;
transition: 0.25s ease;
}
.download-btn {
background: white;
color: #3f51b5;
font-size: 30px;
}
.btn--blue {
background: #4a90e2;
}
.tile {
width: 33.333%;
float: left;
height: 150px;
}
.tile-container {
overflow: hidden;
}
.btn:hover,
.tile:hover {
opacity: 1;
}
.tile:nth-child(2) {
background: #4a90e2;
}
.tile:nth-child(3) {
background: #ffd200;
}
.tile:nth-child(4) {
background: #4cbb47;
}
.tile:nth-child(5) {
background: #362a6c;
}
.tile:nth-child(6) {
background: #4cbb47;
}
.modal {
position: fixed;
inset: 1rem;
padding: 3rem;
background: #ea006f;
color: white;
z-index: 1;
visibility: hidden;
opacity: 0;
pointer-events: none;
transition: 200ms ease;
overflow: auto;
}
.modal-close-btn {
display: block;
position: absolute;
top: 0;
right: 0;
background: url(img/close.png) no-repeat center;
width: 32px;
height: 32px;
padding: 32px;
opacity: 0.8;
cursor: pointer;
transition: 0.3s ease;
}
.modal-close-btn:hover {
opacity: 1;
}
.modal--2 {
background: #4a90e2;
}
.modal--3 {
background: #ffd200;
}
.modal--4 {
background: #4cbb47;
}
.modal--5 {
background: #362a6c;
}
.modal.show {
opacity: 1;
visibility: visible;
pointer-events: auto;
}
.dialog {
background: #4a90e2;
min-width: 300px;
left: 50%;
right: auto;
top: 30%;
bottom: auto;
box-shadow: 0 0 0 3000px rgba(0, 0, 0, 0.4);
transform: translateX(-50%);
}
.sidebar {
left: auto;
width: 300px;
background: #8bc34a;
transform: translateX(100%);
opacity: 1;
visibility: visible;
}
.sidebar.show {
transform: translateX(0);
}
.sidebar__block {
border-radius: 5px;
background: white;
opacity: 0.3;
margin-top: 32px;
}
.quote-box__bubble {
position: relative;
background: white;
padding: 16px;
color: #555;
border-radius: 5px;
max-width: 480px;
margin: 0 auto 20px;
}
.quote-box__bubble:after {
content: "";
display: block;
position: absolute;
top: 100%;
left: 50%;
width: 0;
height: 0;
border: 10px solid transparent;
border-top-color: white;
border-top-width: 10px;
}
.github-ribbon {
position: fixed;
inset: 0 0 auto auto;
background: black;
padding: 0.5rem 1rem;
}
footer {
padding: 50px 0 20px;
}
.footer-text {
opacity: 0.7;
margin-top: 20px;
}
</style>
</head>
<body>
<h1 class="main-title">cta.js</h1>
<p>
cta.js or "Call to Animation" is a light-weight performant library to
animate your "action-to-effect" paths.
</p>
<a
href="https://github.com/chinchang/cta.js#installation"
title="Off to Github"
class="btn download-btn"
>Get started</a
>
<section class="section--white" style="margin-top: 40px">
<h2>What can I use it for?</h2>
<p>Navigation in tile based apps</p>
<small>Click any tile below</small>
<div class="tile-container">
<div
class="tile"
data-cta-target=".js-modal-1"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-2"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-3"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-4"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-5"
style="width: 16.666%"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-4"
data-disable-scroll="true"
></div>
<div
class="tile"
data-cta-target=".js-modal-1"
style="width: 16.666%"
data-disable-scroll="true"
></div>
</div>
</section>
<section class="section--white">
<p>Opening modals on button clicks</p>
<div
class="btn"
data-cta-target=".js-dialog"
data-disable-scroll="true"
style="background: #4a90e2"
>
Click for awesomeness
</div>
</section>
<section class="section--white">
<p>Opening sidebars</p>
<div class="btn" data-cta-target=".js-sidebar">Open the Sidebar</div>
</section>
<section class="section--white">
<p>And just about anything...imagination is the limit</p>
</section>
<section>
<h2>And why do I use it?</h2>
<p>
To improve your user experience by providing
<strong>visual continuity</strong>.
</p>
<div class="quote-box">
<div class="quote-box__bubble">
Carefully choreographed motion design can effectively guide the user’s
attention and focus through multiple steps of a process or procedure,
avoid confusion when layouts change or elements are rearranged, and
improve the overall beauty of the experience.
</div>
<a
href="http://www.google.co.in/design/spec/animation/meaningful-transitions.html"
>Google Material Design</a
>
</div>
</section>
<section class="section--white">
<h2>Browser Support</h2>
<div class="content-wrap">
cta.js currently works in all major browsers.
<br /><br />
For all non-supported browsers, the library does nothing and fallbacks
to normal behavior without any explicit handling in your code.
</div>
</section>
<div class="js-modal-1 modal modal--1">
<span class="modal-close-btn"></span>
<h1>Visual Continuity</h1>
<div class="quote-box">
<div class="quote-box__bubble">
Transitioning between two visual states should be clear, smooth and
effortless and not confuse the user. A well-designed transition does
the heavy lifting and enables the user to clearly understand where
their attention should be focused.
</div>
<a
href="http://www.google.co.in/design/spec/animation/meaningful-transitions.html#meaningful-transitions-visual-continuity"
>Google Material design</a
>
</div>
</div>
<div class="js-modal-2 modal modal--2">
<span class="modal-close-btn"></span>
<h1>Share it if you like it</h1>
<br /><br />
<a
href="https://twitter.com/share"
class="twitter-share-button"
data-size="large"
data-via="chinchang457"
data-related="chinchang457"
data-hashtags="animate,javascript"
>Tweet</a
>
</div>
<div class="js-modal-3 modal modal--3">
<span class="modal-close-btn"></span>
<h1>Customary cat!</h1>
<img src="img/cat.jpg" width="300" alt="" />
<p>You found me :)</p>
</div>
<div class="js-modal-4 modal modal--4">
<span class="modal-close-btn"></span>
<h1>Hierarchical timing</h1>
<div class="quote-box">
<div class="quote-box__bubble">
When building a transition, consider the order and timing of the
elements' movement. Ensure that motion supports the information
hierarchy, conveying what content is most important by creating a path
for the eye to follow.
</div>
<a
href="http://www.google.co.in/design/spec/animation/meaningful-transitions.html#meaningful-transitions-hierarchical-timing"
>Google Material design</a
>
</div>
</div>
<div class="js-modal-5 modal modal--5">
<span class="modal-close-btn"></span>
<h1>Consistent choreography</h1>
<div class="quote-box">
<div class="quote-box__bubble">
A well-choreographed app also provides teachable moments. When
transitioning elements are coordinated, the user's understanding of
the app grows. They "get" the app; they don't feel disoriented by the
animation.
</div>
<a
href="http://www.google.co.in/design/spec/animation/meaningful-transitions.html#meaningful-transitions-consistent-choreography"
>Google Material design</a
>
</div>
</div>
<div class="js-dialog modal dialog" style="text-align: center">
<span class="modal-close-btn"></span>
<h3>Do you think this is Awesome?</h3>
<br />
<a onclick="closeShowingModal(); return;" class="btn btn--blue">Yes</a>
<a onclick="closeShowingModal(); return;" class="btn btn--blue">No</a>
</div>
<div class="js-sidebar modal sidebar">
<span class="modal-close-btn"></span>
<div class="sidebar__block" style="height: 20%"></div>
<div class="sidebar__block" style="height: 40%"></div>
<div class="sidebar__block" style="height: 10%"></div>
</div>
<footer>
<a
href="https://twitter.com/share"
class="twitter-share-button"
data-size="large"
data-via="chinchang457"
data-related="chinchang457"
data-hashtags="animate,javascript"
>Tweet</a
>
<div class="footer-text">
By <a href="https://twitter.com/chinchang457">Kushagra Gour</a> •
<a href="https://github.com/chinchang/cta.js">Source</a> • Made with
JavaScript in India.
</div>
</footer>
<a class="github-ribbon" href="https://github.com/chinchang/cta.js"
>Fork me on Github</a
>
<script src="src/cta.js"></script>
<script>
var closeFn;
function closeShowingModal() {
var showingModal = document.querySelector(".modal.show");
if (!showingModal) return;
showingModal.classList.remove("show");
document.body.classList.remove("disable-mouse");
document.body.classList.remove("disable-scroll");
if (closeFn) {
closeFn();
closeFn = null;
}
}
document.addEventListener("click", function (e) {
var target = e.target;
if (target.dataset.ctaTarget) {
closeFn = cta(
target,
document.querySelector(target.dataset.ctaTarget),
{ relativeToWindow: true },
function showModal(modal) {
modal.classList.add("show");
document.body.classList.add("disable-mouse");
if (target.dataset.disableScroll) {
document.body.classList.add("disable-scroll");
}
}
);
} else if (target.classList.contains("modal-close-btn")) {
closeShowingModal();
}
});
document.addEventListener("keyup", function (e) {
if (e.which === 27) {
closeShowingModal();
}
});
</script>
<script
async="true"
type="text/javascript"
src="http://platform.twitter.com/widgets.js"
></script>
</body>
</html>