Skip to content

Commit 4b82f51

Browse files
committed
translated until line 512
1 parent 13f4b45 commit 4b82f51

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

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

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ Aceste valori sunt rareori folosite, deoarece nu reprezintă o animație reală,
342342

343343
## Event: "transitionend"
344344

345-
When the CSS animation finishes, the `transitionend` event triggers.
345+
Când animația CSS se termină, se declanșează evenimentul `transitionend`.
346346

347-
It is widely used to do an action after the animation is done. Also we can join animations.
347+
Acesta este utilizat pe scară largă pentru a efectua o acțiune după terminarea animației. De asemenea putem uni animațiile.
348348

349-
For instance, the ship in the example below starts to sail there and back when clicked, each time farther and farther to the right:
349+
De exemplu, nava din exemplul de mai jos începe să navigheze încolo și înapoi atunci când se face clic, de fiecare dată tot mai departe spre dreapta:
350350

351351
[iframe src="boat" height=300 edit link]
352352

353-
The animation is initiated by the function `go` that re-runs each time the transition finishes, and flips the direction:
353+
Animația este inițiată de funcția `go` care se reia de fiecare dată când se termină tranziția, și inversează direcția:
354354

355355
```js
356356
boat.onclick = function() {
@@ -359,11 +359,11 @@ boat.onclick = function() {
359359

360360
function go() {
361361
if (times % 2) {
362-
// sail to the right
362+
// navighează la dreapta
363363
boat.classList.remove('back');
364364
boat.style.marginLeft = 100 * times + 200 + 'px';
365365
} else {
366-
// sail to the left
366+
// navighează la stânga
367367
boat.classList.add('back');
368368
boat.style.marginLeft = 100 * times - 200 + 'px';
369369
}
@@ -379,40 +379,40 @@ boat.onclick = function() {
379379
};
380380
```
381381

382-
The event object for `transitionend` has a few specific properties:
382+
Obiectul de eveniment pentru `transitionend` are câteva proprietăți specifice:
383383

384384
`event.propertyName`
385-
: The property that has finished animating. Can be good if we animate multiple properties simultaneously.
385+
: Proprietatea a cărei animație s-a încheiat. Poate fi bună dacă animăm mai multe proprietăți simultan.
386386

387387
`event.elapsedTime`
388-
: The time (in seconds) that the animation took, without `transition-delay`.
388+
: Timpul (în secunde) cât a durat animația, fără `transition-delay`.
389389

390390
## Keyframes
391391

392-
We can join multiple simple animations together using the `@keyframes` CSS rule.
392+
Putem uni mai multe animații simple împreună folosind regula CSS `@keyframes`.
393393

394-
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.
394+
Aceasta specifică "numele" animației și regulile - ce, când și unde să se anime. Apoi folosind proprietatea `animation`, putem atașa animația la element și specifica parametri adiționali pentru aceasta.
395395

396-
Here's an example with explanations:
396+
Iată un exemplu cu explicații:
397397

398398
```html run height=60 autorun="no-epub" no-beautify
399399
<div class="progress"></div>
400400

401401
<style>
402402
*!*
403-
@keyframes go-left-right { /* give it a name: "go-left-right" */
404-
from { left: 0px; } /* animate from left: 0px */
405-
to { left: calc(100% - 50px); } /* animate to left: 100%-50px */
403+
@keyframes go-left-right { /* dați-i un nume: "go-left-right" */
404+
from { left: 0px; } /* animați din stânga: 0px */
405+
to { left: calc(100% - 50px); } /* animați spre stânga: 100%-50px */
406406
}
407407
*/!*
408408
409409
.progress {
410410
*!*
411411
animation: go-left-right 3s infinite alternate;
412-
/* apply the animation "go-left-right" to the element
413-
duration 3 seconds
414-
number of times: infinite
415-
alternate direction every time
412+
/* aplică animația "go-left-right" elementului
413+
durata 3 secunde
414+
număr de ori: infinit
415+
direcție alternativă de fiecare dată
416416
*/
417417
*/!*
418418
@@ -425,45 +425,45 @@ Here's an example with explanations:
425425
</style>
426426
```
427427

428-
There are many articles about `@keyframes` and a [detailed specification](https://drafts.csswg.org/css-animations/).
428+
Sunt multe articole despre `@keyframes` și o [specificație detaliată](https://drafts.csswg.org/css-animations/).
429429

430-
You probably won't need `@keyframes` often, unless everything is in constant motion on your sites.
430+
Probabil că nu veți avea nevoie des de `@keyframes`, decât dacă totul este în continuă mișcare pe site-urile dumneavoastră.
431431

432-
## Performance
432+
## Performanță
433433

434-
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.
434+
Majoritatea proprietăților CSS pot fi animate, deoarece majoritatea acestora sunt valori numerice. De exemplu, `width`, `color`, `font-size` sunt toate numere. Atunci când le animați, browserul modifică treptat aceste numere cadru cu cadru, creând un efect lin.
435435

436-
However, not all animations will look as smooth as you'd like, because different CSS properties cost differently to change.
436+
Cu toate acestea, nu toate animațiile vor arăta la fel de lin pe cât ați dori, deoarece diferite proprietăți CSS costă diferit pentru a fi modificate.
437437

438-
In more technical details, when there's a style change, the browser goes through 3 steps to render the new look:
438+
În detalii mai tehnice, atunci când există o schimbare de stil, browserul parcurge 3 etape pentru a randa noul aspect:
439439

440-
1. **Layout**: re-compute the geometry and position of each element, then
441-
2. **Paint**: re-compute how everything should look like at their places, including background, colors,
442-
3. **Composite**: render the final results into pixels on screen, apply CSS transforms if they exist.
440+
1. **Layout**: se recalculează geometria și poziția fiecărui element, apoi
441+
2. **Paint**: se recalculează cum ar trebui să arate fiecare element la locul lui, inclusiv fundalul, culorile,
442+
3. **Composite**: randează rezultatele finale în pixeli pe ecran, aplică transformările CSS dacă acestea există.
443443

444-
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>.
444+
În timpul unei animații CSS, acest proces se repetă la fiecare cadru. Cu toate acestea, proprietățile CSS care nu afectează niciodată geometria sau poziția, cum ar fi `color`, pot sări peste etapa Layout. Dacă o `color` se schimbă, browserul nu calculează o nouă geometrie, ci trece la Paint -> Composite. Și există puține proprietăți care merg direct la Composite. Puteți găsi o listă mai lungă de proprietăți CSS și ce etape declanșează la <https://csstriggers.com>.
445445

446-
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.
446+
Calculele pot dura ceva timp, mai ales în cazul paginilor cu multe elemente și un layout complex. Iar întârzierile sunt de fapt vizibile pe majoritatea dispozitivelor, ceea ce duce la animații "tremurânde", mai puțin fluide.
447447

448-
Animations of properties that skip the Layout step are faster. It's even better if Paint is skipped too.
448+
Animațiile proprietăților care sar peste etapa Layout sunt mai rapide. Este chiar mai bine dacă este sărit și Paint.
449449

450-
The `transform` property is a great choice, because:
451-
- CSS transforms affect the target element box as a whole (rotate, flip, stretch, shift it).
452-
- CSS transforms never affect neighbour elements.
450+
Proprietatea `transform` este o alegere excelentă, deoarece:
451+
- Transformările CSS afectează caseta elementului țintă ca întreg (o rotește, o întoarce, o întinde, o deplasează).
452+
- Transformările CSS nu afectează niciodată elementele vecine.
453453

454-
...So browsers apply `transform` "on top" of existing Layout and Paint calculations, in the Composite stage.
454+
...Astfel browserele aplică `transform` "peste" calculele existente de Layout și Paint, în etapa Composite.
455455

456-
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.
456+
Cu alte cuvinte, browserul calculează Layout-ul (dimensiuni, poziții), îl pictează cu culori, fundaluri etc în etapa Paint, iar apoi aplică `transform` la casetele de elemente care au nevoie de ea.
457457

458-
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.
458+
Modificările (animațiile) proprietății `transform` nu declanșează niciodată pașii Layout și Paint. Mai mult decât atât, browserul avantajează acceleratorul grafic (un cip special de pe CPU sau de pe placa grafică) pentru transformările CSS, făcându-le astfel foarte eficiente.
459459

460-
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.
460+
Din fericire, proprietatea `transform` este foarte puternică. Utilizând `transform` pe un element, ați putea să-l rotiți și să-l întoarceți, să-l întindeți și să-l micșorați, să-l deplasați și [multe altele](https://developer.mozilla.org/docs/Web/CSS/transform#syntax). Deci în loc de proprietățile `left/margin-left` putem folosi `transform: translateX(…)`, folosi `transform: scale` pentru a mări dimensiunea elementului, etc.
461461

462-
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.
462+
De asemenea proprietatea `opacity` nu declanșează niciodată Layout (de asemenea sare peste Paint în Mozilla Gecko). O putem folosi pentru efecte de afișare/ascundere sau de fade-in/fade-out.
463463

464-
Paring `transform` with `opacity` can usually solve most of our needs, providing fluid, good-looking animations.
464+
Asocierea `transform` cu `opacity` poate rezolva de obicei majoritatea nevoilor noastre, oferind animații fluide și arătoase.
465465

466-
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:
466+
De exemplu, aici apăsând pe elementul `#boat` adaugă clasa cu `transform: translateX(300)` și `opacity: 0`, făcându-l astfel să se deplaseze `300px` spre dreapta și să dispară:
467467

468468
```html run height=260 autorun no-beautify
469469
<img src="https://js.cx/clipart/boat.png" id="boat">
@@ -484,10 +484,10 @@ For example, here clicking on the `#boat` element adds the class with `transform
484484
</script>
485485
```
486486

487-
Here's a more complex example, with `@keyframes`:
487+
Iată un exemplu mai complex, cu `@keyframes`:
488488

489489
```html run height=80 autorun no-beautify
490-
<h2 onclick="this.classList.toggle('animated')">click me to start / stop</h2>
490+
<h2 onclick="this.classList.toggle('animated')">apasă-mă pentru start / stop</h2>
491491
<style>
492492
.animated {
493493
animation: hello-goodbye 1.8s infinite;

0 commit comments

Comments
 (0)