-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
547 lines (500 loc) · 19.9 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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Movigo library</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="Movigo library core with base features to animate your DOM elements.">
<meta name="author" content="Omar Desogus">
<meta name="keywords" lang="en" content="js-animations animations animations-library">
<meta name="language" content="en"/>
<meta name="rating" content="general"/>
<link rel="shortcut icon" href="/resources/favicon.ico" type="image/x-icon">
<link rel="icon" href="/resources/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="./layout.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/zenburn.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
<script src="https://unpkg.com/@movigo/core"></script>
<script src="/dist/movigo.js"></script>
<script src="https://unpkg.com/@movigo/list"></script>
<script src="https://unpkg.com/@movigo/focus"></script>
<script src="https://unpkg.com/@movigo/drawer"></script>
</head>
<body>
<!-- GitHub corner icon -->
<a class="github-corner" href="https://github.com/movigo/core" target="_blank">
<svg width="80" height="80" viewBox="0 0 250 250">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
<path class="octo-arm" style="transform-origin: 130px 106px;" fill="currentColor"
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2">
</path>
<path class="octo-body" fill="currentColor"
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z">
</path>
</svg>
</a>
<!-- Website header: logo | description | library strengths -->
<header>
<div>
<div id="logo">
<img src="/resources/icon.png">
</div>
<div id="preamble">
<h1>Movigo.js</h1>
<p>
Ultralight JS library to animate your DOM elements.
You can find library documentation on
<a href="http://movigo.rtfd.io/" target="_blank">http://movigo.rtfd.io/</a>.
</p>
</div>
</div>
<div id="strengths">
<ul>
<li><span>✔</span> Light (~3kb)</li>
<li><span>✔</span> Modern</li>
<li><span>✔</span> Easy to use</li>
</ul>
</div>
</header>
<!-- Boxes where the various features can be shown with examples -->
<div id="examples">
<div>
<div class="animation">
<span onclick="animation1(this)" class="play-button" title="Play animation">‣</span>
<div style="background-color: darkred"></div>
</div>
<div>
<div>
<h3>Functions</h3>
<p>
First function to call is always <b>target</b> function, which takes a selector, a DOM element or more DOM
elements as input and return an object of functions. We can divide these functions into
<b>action</b> functions, <b>option</b> functions and <b>plugin</b> functions.
Every action, option or plugin function return the same object of functions, with a final function:
<b>animate</b>, that plays the animation and return a
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"
target="_blank">promise</a>
(fulfilled at the and of the created animations). Click on `play` button at top left to play animations.
</p>
</div>
<pre class="code"><code class="js">
const target = movigo.target('div')
// or:
const element = document.querySelector('div')
const target = movigo.target(element)
target.duration(.8) // Option function.
target.to({ width: '200px' }) // Action function.
target.list() // List plugin function.
// Create the animation and wait for the end.
await target.duration(.8).to({ width: '200px' }).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation2(this)" class="play-button" title="Play animation">‣</span>
<div style="background-color: darkolivegreen"></div>
</div>
<div>
<div>
<h3>Method chaining</h3>
<p>
As you can see Movigo use
<a href="https://en.wikipedia.org/wiki/Method_chaining" target="_blank">method chaining</a>
technique, and save the state of the animation in each function. This means that you can break the
chain and create new chains with additional functions by building different animations.
</p>
</div>
<pre class="code"><code class="js">
const slowAnimation = target.duration(1)
await slowAnimation.to({ width: '100px' }).animate()
await slowAnimation.to({ height: '100px' }).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation3(this)" class="play-button" title="Play animation">‣</span>
<div style="background-color: chocolate"></div>
</div>
<div>
<div>
<h3>Actions</h3>
<p>
Action functions allow you to change CSS property values. There are currently two function:
<b>to</b> and <b>from</b>. Both take an object containing CSS properties and they work like in
a CSS keyframe: <b>from</b> values represent the initial state of the animation,
<b>to</b> values represent the final state. If <b>from</b> function is not defined, the initial state is
represented by the current CSS target properties. To see a full list of available
actions you can also use <b>movigo.actions()</b> function.
</p>
</div>
<pre class="code"><code class="js">
await target.duration(.3).to({
width: '80px',
height: '80px',
borderRadius: '100%',
transform: 'rotateZ(90deg) translateY(-100px)'
}).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation4(this)" class="play-button" title="Play animation">‣</span>
<div style="background-color: darkcyan"></div>
</div>
<div>
<div>
<h3>Options</h3>
<p>
Option functions allow you to set some properties of the animations, such as duration,
speed curve of the transition effect, delays or loops.
The number parameter of <b>delay</b> and <b>duration</b> functions must be defined in seconds,
<b>easing</b> function parameter values can be found in W3S documentation and <b>loop</b> function
take a number of loops or nothing (infinite loop).
To see a full list of available options you can use <b>movigo.options()</b> function.
</p>
</div>
<pre class="code"><code class="js">
await target
.delay(.5).duration(.8)
.easing('ease-in-out')
.loop(2)
.to({
width: '80px',
height: '80px',
transform: 'rotateZ(180deg)'
}).animate()
// Infinite loop:
// target.loop().to({ left: '100px' }).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation5(this)" class="play-button" title="Play animation">‣</span>
<div id="text-animation">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div>
</div>
<div>
<div>
<h3>Specific parameters</h3>
<p>
Option and action functions can get a function as parameter, in which i-th element can be used to
define specific element options or actions.
</p>
</div>
<pre class="code"><code class="js">
const letters = document.querySelectorAll('span')
const target = movigo.target(letters)
await target
.delay((i, el) => i * .05).duration(.4)
.easing('cubic-bezier(0.4, 0.0, 0.2, 1)')
.to({ opacity: 1 }).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation6(this)" class="play-button" title="Play animation">‣</span>
<div id="button-animation">
♥
</div>
</div>
<div>
<div>
<h3>Feedback</h3>
<p>
You can create simple animations to make your UI more user-friendly with feedback.
</p>
</div>
<pre class="code"><code class="js">
await target
.duration(.1).loop(1)
.easing('cubic-bezier(0.33, 1, 0.68, 1)')
.to({ transform: 'scale(2, 2)', opacity: .3 })
.animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation7(this)" class="play-button" title="Play animation">‣</span>
<div id="loading-animation">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<div>
<div>
<h3>Loading</h3>
<p>
You can create loading animations with a few lines of code.
</p>
</div>
<pre class="code"><code class="js">
await target
.delay(i => i * .1).duration(.4).loop(5)
.to({ transform: 'scaleY(1.5)', opacity: .6 })
.animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation8(this)" class="play-button" title="Play animation">‣</span>
<div class="screen">
<ul>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
</ul>
</div>
</div>
<div>
<div>
<h3>List plugin</h3>
<p>
<a href="https://github.com/movigo/list" target="_blank">List plugin</a>
allows you to create and manage animations for lists of elements,
with slide-in and fade-in effects.
</p>
</div>
<pre class="code"><code class="js">
const elements = document.querySelectorAll('ul > li')
const target = movigo.target(elements)
await target.list().animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation9(this)" class="play-button" title="Play animation">‣</span>
<div id="focus-animation" class="screen">
<img src="https://cdn.audleytravel.com/-/-/79/1338050-colosseum-rome.jpg">
<img src="https://4.bp.blogspot.com/-V9lFhJJZPwI/UQgN0JXUDDI/AAAAAAAAjwQ/ZgSE0j8w-ZQ/s1600/indie-paris-eiffel-tower-jpg-1189976.jpg">
<img src="http://athenaposters.ca/wp-content/uploads/2017/05/2400-0764-London-Big-Ben-36x24.jpg">
<img src="https://footage.framepool.com/shotimg/qf/874025235-atom-model-atomium-brussels-sfere-form.jpg">
</div>
</div>
<div>
<div>
<h3>Focus</h3>
<p>
<a href="https://github.com/movigo/focus" target="_blank">Focus plugin</a> allows you to
create animations to focus particular elements by scaling an element and
obscuring the other background elements.
</p>
</div>
<pre class="code"><code class="js">
const images = document.querySelectorAll('img')
const target = movigo.target(images)
await target.focus({
element: 1 // Index of focused element.
}).animate()
</code></pre>
</div>
</div>
<div>
<div class="animation">
<span onclick="animation10(this)" class="play-button" title="Play animation">‣</span>
<div id="drawer-animation" class="screen">
<img src="https://cdn.audleytravel.com/-/-/79/1338050-colosseum-rome.jpg"
style="width: 150px; height: 90px; margin-bottom: 5px">
<ul>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
</ul>
<nav class="sidenav">
<ul>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
<li>
<div></div>
<div></div>
</li>
</ul>
</nav>
</div>
</div>
<div>
<div>
<h3>Drawer</h3>
<p>
<a href="https://github.com/movigo/drawer" target="_blank">Drawer plugin</a> allows you to
animate sidebars by creating a slide effect and obscuring the background container.
</p>
</div>
<pre class="code"><code class="js">
const sidenav = document.querySelector('.sidenav')
const container = document.querySelector('.container')
const target = movigo.target([sidenav, container])
await target.drawer().animate()
</code></pre>
</div>
</div>
</div>
<footer>
<div>
<a href="https://cedoor.dev" target="_blank">
☯ cedoor.dev
</a>
</div>
<div>
Copyright (c) 2020 Omar Desogus
</div>
</footer>
</body>
<script>
hljs.initHighlightingOnLoad()
const toggleAnimation = {}
async function animation1 (element) {
const target = movigo.target(element.nextElementSibling)
await target.duration(.1).to({ width: '50px', }).animate()
await target.duration(.8).to({ width: '200px' }).animate()
}
async function animation2 (element) {
const target = movigo.target(element.nextElementSibling)
await target.duration(.1).to({
width: '50px',
height: '50px'
}).animate()
const animation = target.duration(1)
await animation.to({ width: '100px' }).animate()
await animation.to({ height: '100px' }).animate()
}
async function animation3 (element) {
const target = movigo.target(element.nextElementSibling)
await target.duration(.1).to({
width: '50px',
height: '50px',
borderRadius: '0',
transform: 'rotateZ(0) translateY(0)'
}).animate()
await target.duration(.3).to({
width: '80px',
height: '80px',
borderRadius: '100%',
transform: 'rotateZ(90deg) translateY(-100px)'
}).animate()
}
async function animation4 (element) {
const target = movigo.target(element.nextElementSibling)
await target
.delay(.5).duration(.8)
.easing('ease-in-out')
.loop(2)
.to({
width: '80px',
height: '80px',
transform: 'rotateZ(180deg)'
}).animate()
}
async function animation5 (element) {
const originalText = element.nextElementSibling.innerText
element.nextElementSibling.innerHTML = originalText.split('').reduce((a, l) => a += l === ' ' ? l : `<span>${l}</span>`, '')
const elements = element.nextElementSibling.querySelectorAll('span')
const target = movigo.target(elements)
await target.duration(.1).to({ opacity: 0 }).animate()
await target
.delay(i => i * .05).duration(.4)
.easing('cubic-bezier(0.4, 0.0, 0.2, 1)')
.to({ opacity: 1 }).animate()
element.nextElementSibling.innerText = originalText
}
async function animation6 (element) {
const target = movigo.target(element.nextElementSibling)
await target
.duration(.1).loop(1)
.easing('cubic-bezier(0.33, 1, 0.68, 1)')
.to({ transform: 'scale(2, 2)', opacity: .3 })
.animate()
}
async function animation7 (element) {
const elements = element.nextElementSibling.querySelectorAll('div')
const target = movigo.target(elements)
await target
.delay(i => i * .1).duration(.4).loop(5)
.to({ transform: 'scaleY(1.5)', opacity: .6 })
.animate()
}
async function animation8 (element) {
toggleAnimation.animation8 = !toggleAnimation.animation8
const duration = toggleAnimation.animation8 ? .3 : 1.5
const elements = element.nextElementSibling.querySelectorAll('li')
await movigo.target(elements).list({ duration }).animate()
}
async function animation9 (element) {
toggleAnimation.animation9 = !toggleAnimation.animation9
const elementIndex = toggleAnimation.animation9 ? 1 : 0
const duration = toggleAnimation.animation9 ? .3 : 1.5
const elements = element.nextElementSibling.querySelectorAll('img')
await movigo.target(elements)
.focus({ element: elementIndex })
.duration(duration)
.animate()
}
async function animation10 (element) {
toggleAnimation.animation10 = !toggleAnimation.animation10
const sidenav = element.nextElementSibling.querySelector('.sidenav')
const open = toggleAnimation.animation10
await movigo.target(sidenav).drawer({
width: 120,
open
}).animate()
}
</script>
</html>