You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 935199a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: 7-animation/2-css-animations/article.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -318,17 +318,17 @@ CSS:
318
318
319
319
Ці значення рідко використовуються, тому що це насправді не анімація, а однокрокова зміна.
320
320
321
-
## Event transitionend
321
+
## Подія transitionend
322
322
323
-
When the CSS animation finishes the`transitionend` event triggers.
323
+
Коли закінчується CSS анімація, запускається подія`transitionend`.
324
324
325
-
It is widely used to do an action after the animation is done. Also we can join animations.
325
+
Вона широко використовується для виконання дії після завершення анімації. Також ми можемо приєднатися до анімації з її допомогою.
326
326
327
-
For instance, the ship in the example below starts to sail there and back when clicked, each time farther and farther to the right:
327
+
Наприклад, якщо натиснути на корабель у наведеному нижче прикладі, він починає плисти туди й назад, щоразу все далі й далі праворуч:
328
328
329
329
[iframe src="boat" height=300 edit link]
330
330
331
-
The animation is initiated by the function `go` that re-runs each time the transition finishes, and flips the direction:
331
+
Анімація ініціюється функцією `go`, яка повторно запускається кожного разу, коли закінчується перехід, і повертає напрямок:
332
332
333
333
```js
334
334
boat.onclick=function() {
@@ -337,11 +337,11 @@ boat.onclick = function() {
337
337
338
338
functiongo() {
339
339
if (times %2) {
340
-
//sail to the right
340
+
//пливти праворуч
341
341
boat.classList.remove('back');
342
342
boat.style.marginLeft=100* times +200+'px';
343
343
} else {
344
-
//sail to the left
344
+
//пливти ліворуч
345
345
boat.classList.add('back');
346
346
boat.style.marginLeft=100* times -200+'px';
347
347
}
@@ -357,40 +357,40 @@ boat.onclick = function() {
357
357
};
358
358
```
359
359
360
-
The event object for `transitionend`has a few specific properties:
360
+
Об’єкт події для `transitionend`має кілька конкретних властивостей:
361
361
362
362
`event.propertyName`
363
-
: The property that has finished animating. Can be good if we animate multiple properties simultaneously.
363
+
: Властивість, яка завершила анімацію. Може бути корисна коли ми анімуємо кілька властивостей одночасно.
364
364
365
365
`event.elapsedTime`
366
-
: The time (in seconds) that the animation took, without`transition-delay`.
366
+
: Час (у секундах), який займала анімація, без`transition-delay`.
367
367
368
-
## Keyframes
368
+
## Ключові кадри
369
369
370
-
We can join multiple simple animations together using the `@keyframes` CSS rule.
370
+
Ми можемо об’єднати кілька простих анімацій разом за допомогою правила CSS `@keyframes`.
371
371
372
-
It specifies the "name" of the animation and rules - what, when and where to animate. Then using the `animation` property, we can attach the animation to the element and specify additional parameters for it.
372
+
Воно визначає "ім’я" анімації та правила - що, коли і де анімувати. Використовуючи властивість `animation`, ми можемо приєднати анімацію до елемента та вказати додаткові параметри.
373
373
374
-
Here's an example with explanations:
374
+
Ось приклад із поясненнями:
375
375
376
376
```html run height=60 autorun="no-epub" no-beautify
377
377
<divclass="progress"></div>
378
378
379
379
<style>
380
380
*!*
381
-
@keyframesgo-left-right { /*give it a name: "go-left-right" */
382
-
from { left: 0px; } /*animate from left: 0px */
383
-
to { left: calc(100%-50px); } /*animate to left: 100%-50px */
from { left: 0px; } /*початок анімації від left: 0px */
383
+
to { left: calc(100%-50px); } /*кінець анімації до left: 100%-50px */
384
384
}
385
385
*/!*
386
386
387
387
.progress {
388
388
*!*
389
389
animation: go-left-right 3sinfinitealternate;
390
-
/*apply the animation "go-left-right" to the element
391
-
duration 3 seconds
392
-
number of times: infinite
393
-
alternate direction every time
390
+
/*застосувати анімацію "go-left-right" до еменета
391
+
тривалість 3 секунди
392
+
кількість разів: нескінченно
393
+
щоразу змінювати напрямок
394
394
*/
395
395
*/!*
396
396
@@ -403,11 +403,11 @@ Here's an example with explanations:
403
403
</style>
404
404
```
405
405
406
-
There are many articles about `@keyframes`and a [detailed specification](https://drafts.csswg.org/css-animations/).
406
+
Є багато статей про `@keyframes`та [датальна специфікація](https://drafts.csswg.org/css-animations/).
407
407
408
-
You probably won't need `@keyframes`often, unless everything is in constant motion on your sites.
408
+
Ймовірно, `@keyframes`не знадобляться вам часто, хіба якщо на ваших сайтах все постійно рухається.
409
409
410
-
## Performance
410
+
## Продуктивність
411
411
412
412
Most CSS properties can be animated, because most of them are numeric values. For instance, `width`, `color`, `font-size` are all numbers. When you animate them, the browser gradually changes these numbers frame by frame, creating a smooth effect.
0 commit comments