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
Copy file name to clipboardExpand all lines: 7-animation/2-css-animations/article.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -421,9 +421,9 @@ In more technical details, when there's a style change, the browser goes through
421
421
422
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.
423
423
424
-
The Layout step is by far the most expensive: geometry calculations 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
+
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.
425
425
426
-
**The general recomendation is to animate properties that don't do Layout.**
426
+
The animations of properties that skip the Layout and Paint steps are faster.
427
427
428
428
For most CSS properties, the rule is simple: if its change may affect geometry, move elements (even in theory), then it triggers Layout. Otherwise (e.g. a `color` change may not shift elements around), the browser doesn't need to calculate geometry and directly goes to Paint, or even Composite step. You can find a longer list of CSS properties and which stages they trigger at <https://csstriggers.com>.
429
429
@@ -435,11 +435,11 @@ So browsers apply `transform` "on top" of existing Layout and Paint calculations
435
435
436
436
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.
437
437
438
-
Animating the `transform` property never causes Layout and Paint. 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 effecient.
438
+
Changes (animations) of the `transform` property never cause 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 effecient.
439
439
440
440
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).
441
441
442
-
The `opacity` property also never causes Layout. We can use it for show / hide or fade-in / fade-out effects.
442
+
The `opacity` property also never causes Layout (also skips Paint in Gecko). We can use it for show / hide or fade-in / fade-out effects.
443
443
444
444
Paring `transform` with `opacity` can usually solve most of our needs, providing fluid, good-looking animations.
0 commit comments