Skip to content

Commit 5f35c46

Browse files
authored
Update article.md
100%
1 parent 935199a commit 5f35c46

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

‎7-animation/2-css-animations/article.md‎

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -409,39 +409,39 @@ boat.onclick = function() {
409409

410410
## Продуктивність
411411

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.
412+
Більшість властивостей CSS можна анімувати, оскільки більшість із них є числовими значеннями. Наприклад, `width`, `color`, `font-size` є числами. Коли ви анімуєте їх, браузер поступово змінює ці числа кадр за кадром, створюючи плавний ефект.
413413

414-
However, not all animations will look as smooth as you'd like, because different CSS properties cost differently to change.
414+
Однак не всі анімації виглядатимуть так гладко, як хотілося б, оскільки різні властивості змінюються по-різному.
415415

416-
In more technical details, when there's a style change, the browser goes through 3 steps to render the new look:
416+
Якщо говорити більше про технічні деталі, коли відбувається зміна стилю, браузер виконує 3 кроки для відтворення нового вигляду:
417417

418-
1. **Layout**: re-compute the geometry and position of each element, then
419-
2. **Paint**: re-compute how everything should look like at their places, including background, colors,
420-
3. **Composite**: render the final results into pixels on screen, apply CSS transforms if they exist.
418+
1. **Макет**: перерахувати геометрію, а потім положення кожного елемента
419+
2. **Фарбування**: перерахувати, як все має виглядати на своїх місцях, включаючи фон, кольори,
420+
3. **Композиція**: відтворити кінцеві результати в пікселях на екрані, застосувати CSS-перетворення, якщо вони існують.
421421

422-
During a CSS animation, this process repeats every frame. However, CSS properties that never affect geometry or position, such as `color`, may skip the Layout step. If a `color` changes, the browser doesn't calculate any new geometry, it goes to Paint -> Composite. And there are few properties that directly go to Composite. You can find a longer list of CSS properties and which stages they trigger at <https://csstriggers.com>.
422+
Під час CSS-анімації цей процес повторюється для кожного кадра. Однак властивості CSS, які ніколи не впливають на геометрію або положення, наприклад, `color`, можуть пропускатись кроці макета. Якщо `color` змінюється, браузер не обчислює нову геометрію, він переходить до кроків Фарбування -> Композиція. І є кілька властивостей, які безпосередньо переходять до Композиції. Ви можете знайти довший список властивостей CSS та на яких етапах вони запускаються тут <https://csstriggers.com>.
423423

424-
The calculations may take time, especially on pages with many elements and a complex layout. And the delays are actually visible on most devices, leading to "jittery", less fluid animations.
424+
Обчислення може зайняти багато часу, особливо на сторінках із великою кількістю елементів і складним макетом. І затримки фактично помітні на більшості пристроїв, що призводить до «тривожності», менш плавної анімації.
425425

426-
Animations of properties that skip the Layout step are faster. It's even better if Paint is skipped too.
426+
Анімація властивостей, які пропускають крок макета, швидше. Навіть ліпше, ніж у випадку з пропусканням кроку фарбування.
427427

428-
The `transform` property is a great choice, because:
429-
- CSS transforms affect the target element box as a whole (rotate, flip, stretch, shift it).
430-
- CSS transforms never affect neighbour elements.
428+
Властивість `transform` є чудовим вибором, оскільки:
429+
- Перетворення CSS впливають на блок цільового елемента в цілому (повертають, перевертають, розтягують, зміщують його).
430+
- CSS-перетворення ніколи не впливають на сусідні елементи.
431431

432-
...So browsers apply `transform` "on top" of existing Layout and Paint calculations, in the Composite stage.
432+
...Тому браузери застосовують `transform` "попереду" наявних обчислень Макету та Фарбування на етапі Композиції.
433433

434-
In other words, the browser calculates the Layout (sizes, positions), paints it with colors, backgrounds, etc at the Paint stage, and then applies `transform` to element boxes that need it.
434+
Іншими словами, браузер обчислює макет (розміри, положення), розфарбовує його за допомогою colors, background тощо на етапі Фарбування, а потім застосовує `transform` до блоків елементів, які цього потребують.
435435

436-
Changes (animations) of the `transform` property never trigger Layout and Paint steps. More than that, the browser leverages the graphics accelerator (a special chip on the CPU or graphics card) for CSS transforms, thus making them very efficient.
436+
Зміни (анімації) властивості `transform` ніколи не запускають кроки Макет та Фарбування. Більше того, браузер використовує графічний прискорювач (спеціальний чіп на ЦП або відеокарті) для CSS-перетворень, що робить їх дуже ефективними.
437437

438-
Luckily, the `transform` property is very powerful. By using `transform` on an element, you could rotate and flip it, stretch and shrink it, move it around, and [much more](https://developer.mozilla.org/docs/Web/CSS/transform#syntax). So instead of `left/margin-left` properties we can use `transform: translateX(…)`, use `transform: scale` for increasing element size, etc.
438+
На щастя, властивість `transform` дуже потужна. Використовуючи `transform` для елемента, ви можете обертати та повертати його, розтягувати та зменшувати, переміщувати та [багато іншого](https://developer.mozilla.org/docs/Web/CSS/transform#syntax ). Тому замість властивостей `left/margin-left` ми можемо використовувати `transform: translateX(…)`, `transform: scale` для збільшення розміру елемента, тощо.
439439

440-
The `opacity` property also never triggers Layout (also skips Paint in Mozilla Gecko). We can use it for show/hide or fade-in/fade-out effects.
440+
Властивість `opacity` ніколи не запускає Макет (в Mozilla Gecko також пропускається Фарбування). Ми можемо використовувати його для ефектів відображення/приховування або посилення/згасання.
441441

442-
Paring `transform` with `opacity` can usually solve most of our needs, providing fluid, good-looking animations.
442+
Поєднання `transform` з `opacity` зазвичай може вирішувати більшість наших потреб, забезпечуючи плавну, гарну анімацію.
443443

444-
For example, here clicking on the `#boat` element adds the class with `transform: translateX(300)` and `opacity: 0`, thus making it move `300px` to the right and disappear:
444+
Наприклад, тут клік на елемент `#boat` додає клас із `transform: translateX(300)` та `opacity: 0`, таким чином змушуючи його рухатись на `300px` праворуч і зникати:
445445

446446
```html run height=260 autorun no-beautify
447447
<img src="https://js.cx/clipart/boat.png" id="boat">
@@ -462,10 +462,10 @@ For example, here clicking on the `#boat` element adds the class with `transform
462462
</script>
463463
```
464464

465-
Here's a more complex example, with `@keyframes`:
465+
Ось більш складний приклад із `@keyframes`:
466466

467467
```html run height=80 autorun no-beautify
468-
<h2 onclick="this.classList.toggle('animated')">click me to start / stop</h2>
468+
<h2 onclick="this.classList.toggle('animated')">натисніть на мене, щоб почати/зупинити</h2>
469469
<style>
470470
.animated {
471471
animation: hello-goodbye 1.8s infinite;
@@ -488,23 +488,23 @@ Here's a more complex example, with `@keyframes`:
488488
</style>
489489
```
490490

491-
## Summary
491+
## Підсумки
492492

493-
CSS animations allow smoothly (or step-by-step) animated changes of one or multiple CSS properties.
493+
Анімація CSS дозволяє плавно (або покроково) анімувати зміну однієї або кількох властивостей CSS.
494494

495-
They are good for most animation tasks. We're also able to use JavaScript for animations, the next chapter is devoted to that.
495+
Вона гарна для більшості завданнь анімації. Ми також можемо використовувати JavaScript для анімації, цьому присвячений наступний розділ.
496496

497-
Limitations of CSS animations compared to JavaScript animations:
497+
Обмеження анімації CSS порівняно з JavaScript:
498498

499499
```compare plus="CSS animations" minus="JavaScript animations"
500-
+ Simple things done simply.
501-
+ Fast and lightweight for CPU.
502-
- JavaScript animations are flexible. They can implement any animation logic, like an "explosion" of an element.
503-
- Not just property changes. We can create new elements in JavaScript as part of the animation.
500+
+ Прості речі робляться просто.
501+
+ Швидка та легкиа для процесора.
502+
- Анімації JavaScript є гнучкими. Вони можуть реалізувати будь-яку логіку анімації, навіть «вибух» елемента.
503+
- Не тільки властивості змінюються. В JavaScript ми можемо створювати нові елементи як частину анімації.
504504
```
505505

506-
In early examples in this chapter, we animate `font-size`, `left`, `width`, `height`, etc. In real life projects, we should use `transform: scale()` and `transform: translate()` for better performance.
506+
У перших прикладах цього розділу ми анімували `font-size`, `left`, `width`, `height` тощо. У реальних проектах ми повинні використовувати `transform: scale()` і `transform: translate()` для кращої продуктивності.
507507

508-
The majority of animations can be implemented using CSS as described in this chapter. And the `transitionend` event allows JavaScript to be run after the animation, so it integrates fine with the code.
508+
Більшість анімацій можна реалізувати за допомогою CSS, як описано в цьому розділі. А подія `transitionend` дозволяє запускати JavaScript після анімації, тому вона добре інтегрується з кодом.
509509

510-
But in the next chapter we'll do some JavaScript animations to cover more complex cases.
510+
Але в наступному розділі ми зробимо кілька анімацій JavaScript, щоб охопити більш складні випадки.

0 commit comments

Comments
 (0)