Skip to content

Commit 090ee4e

Browse files
authored
Update article.md
1 parent a1a86dd commit 090ee4e

1 file changed

Lines changed: 36 additions & 35 deletions

File tree

7-animation/3-js-animation/article.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,21 @@ function elastic(x, timeFraction) {
312312

313313
[iframe height=40 src="elastic" link]
314314

315-
## Reversal: ease*
315+
## معکوس: ease*
316316

317-
So we have a collection of timing functions. Their direct application is called "easeIn".
317+
بنابراین ما مجموعه ای از توابع زمان بندی داریم. کاربرد مستقیم آنها `easeIn` نامیده می شود.
318318

319-
Sometimes we need to show the animation in the reverse order. That's done with the "easeOut" transform.
319+
گاهی اوقات لازم است انیمیشن را به ترتیب معکوس نشان دهیم. این کار با تبدیل `easeOut` انجام می شود.
320320

321321
### easeOut
322322

323-
In the "easeOut" mode the `timing` function is put into a wrapper `timingEaseOut`:
323+
در حالت `easeOut` تابع `timing` در لفاف `timingEaseOut` قرار می گیرد:
324324

325325
```js
326326
timingEaseOut(timeFraction) = 1 - timing(1 - timeFraction)
327327
```
328328

329-
In other words, we have a "transform" function `makeEaseOut` that takes a "regular" timing function and returns the wrapper around it:
329+
به عبارت دیگر، ما یک تابع `تغییر` `makeEaseOut` داریم که یک تابع زمان بندی "عادی" را می گیرد و پوشش دور آن را برمی گرداند:
330330

331331
```js
332332
// accepts a timing function, returns the transformed variant
@@ -337,32 +337,31 @@ function makeEaseOut(timing) {
337337
}
338338
```
339339

340-
For instance, we can take the `bounce` function described above and apply it:
340+
برای مثال، می‌توانیم تابع `جهش` که در بالا توضیح داده شد را گرفته و آن را اعمال کنیم:
341341

342342
```js
343343
let bounceEaseOut = makeEaseOut(bounce);
344344
```
345345

346-
Then the bounce will be not in the beginning, but at the end of the animation. Looks even better:
346+
سپس پرش نه در ابتدا، بلکه در انتهای انیمیشن خواهد بود. حتی بهتر به نظر می رسد:
347347

348348
[codetabs src="bounce-easeout"]
349349

350-
Here we can see how the transform changes the behavior of the function:
350+
در اینجا می توانیم ببینیم که چگونه تبدیل رفتار تابع را تغییر می دهد:
351351

352352
![](bounce-inout.svg)
353353

354-
If there's an animation effect in the beginning, like bouncing -- it will be shown at the end.
354+
اگر در ابتدا یک افکت انیمیشن وجود داشته باشد، مانند پرش -- در انتها نشان داده می شود.
355355

356-
In the graph above the <span style="color:#EE6B47">regular bounce</span> has the red color, and the <span style="color:#62C0DC">easeOut bounce</span> is blue.
357-
358-
- Regular bounce -- the object bounces at the bottom, then at the end sharply jumps to the top.
359-
- After `easeOut` -- it first jumps to the top, then bounces there.
356+
در نمودار بالا، <span style="color:#EE6B47">پرش منظم</span> رنگ قرمز دارد و <span style="color:#62C0DC">easeOut bounce</span> آبی است.
360357

358+
- پرش منظم - جسم در پایین می پرد، سپس در انتها به شدت به بالا می پرد.
359+
- بعد از `easeOut` - ابتدا به بالا می پرد، سپس به آنجا می پرد.
361360
### easeInOut
362361

363-
We also can show the effect both in the beginning and the end of the animation. The transform is called "easeInOut".
362+
ما همچنین می توانیم اثر را هم در ابتدا و هم در انتهای انیمیشن نشان دهیم. تبدیل `easeInOut` نامیده می شود.
364363

365-
Given the timing function, we calculate the animation state like this:
364+
با توجه به تابع زمان بندی، حالت انیمیشن را به صورت زیر محاسبه می کنیم:
366365

367366
```js
368367
if (timeFraction <= 0.5) { // first half of the animation
@@ -372,7 +371,7 @@ if (timeFraction <= 0.5) { // first half of the animation
372371
}
373372
```
374373

375-
The wrapper code:
374+
کد wrraper:
376375

377376
```js
378377
function makeEaseInOut(timing) {
@@ -387,37 +386,39 @@ function makeEaseInOut(timing) {
387386
bounceEaseInOut = makeEaseInOut(bounce);
388387
```
389388

390-
In action, `bounceEaseInOut`:
389+
در عمل, `bounceEaseInOut`:
391390

392391
[codetabs src="bounce-easeinout"]
393392

394-
The "easeInOut" transform joins two graphs into one: `easeIn` (regular) for the first half of the animation and `easeOut` (reversed) -- for the second part.
393+
تبدیل `easeInOut` دو نمودار را به یک نمودار می پیوندد: `easeIn` (عادی) برای نیمه اول انیمیشن و `easeOut` (معکوس) -- برای قسمت دوم.
395394

396-
The effect is clearly seen if we compare the graphs of `easeIn`, `easeOut` and `easeInOut` of the `circ` timing function:
395+
اگر نمودارهای `easeIn`، `easeOut` و `easeInOut` تابع زمانبندی `circ` را با هم مقایسه کنیم، این اثر به وضوح مشاهده می شود:
397396

398397
![](circ-ease.svg)
399398

400-
- <span style="color:#EE6B47">Red</span> is the regular variant of `circ` (`easeIn`).
399+
- <span style="color:#EE6B47">Red</span> نوع معمولی است `circ` (`easeIn`).
401400
- <span style="color:#8DB173">Green</span> -- `easeOut`.
402401
- <span style="color:#62C0DC">Blue</span> -- `easeInOut`.
403402

404-
As we can see, the graph of the first half of the animation is the scaled down `easeIn`, and the second half is the scaled down `easeOut`. As a result, the animation starts and finishes with the same effect.
403+
همانطور که می بینیم، نمودار نیمه اول انیمیشن `easeIn` کوچک شده و نیمه دوم `easeOut` کوچک شده است. در نتیجه انیمیشن با همان افکت شروع و به پایان می رسد.
404+
405405

406-
## More interesting "draw"
406+
## نکته جالب تر "draw"
407407

408-
Instead of moving the element we can do something else. All we need is to write the proper `draw`.
408+
به جای جابجایی عنصر می توانیم کار دیگری انجام دهیم. تنها چیزی که نیاز داریم این است که `draw` مناسب را بنویسیم.
409409

410-
Here's the animated "bouncing" text typing:
410+
در اینجا تایپ متن متحرک `bouncing` آمده است:
411411

412412
[codetabs src="text"]
413413

414-
## Summary
414+
## خلاصه
415+
416+
برای انیمیشن هایی که CSS نمی تواند به خوبی از عهده آنها برآید، یا آنهایی که نیاز به کنترل دقیق دارند، جاوا اسکریپت می تواند کمک کند. انیمیشن های جاوا اسکریپت باید از طریق `requestAnimationFrame` پیاده سازی شوند. این روش داخلی به شما امکان می‌دهد تا زمانی که مرورگر در حال آماده‌سازی رنگ‌آمیزی مجدد است، یک تابع پاسخ به تماس را تنظیم کنید. معمولاً خیلی زود است، اما زمان دقیق به مرورگر بستگی دارد.
415417

416-
For animations that CSS can't handle well, or those that need tight control, JavaScript can help. JavaScript animations should be implemented via `requestAnimationFrame`. That built-in method allows to setup a callback function to run when the browser will be preparing a repaint. Usually that's very soon, but the exact time depends on the browser.
418+
وقتی یک صفحه در پس‌زمینه است، هیچ رنگ‌آمیزی مجدد وجود ندارد، بنابراین تماس برگشتی اجرا نمی‌شود: انیمیشن به حالت تعلیق در می‌آید و منابع را مصرف نمی‌کند. عالیه.
417419

418-
When a page is in the background, there are no repaints at all, so the callback won't run: the animation will be suspended and won't consume resources. That's great.
420+
در اینجا تابع کمکی `animate` برای تنظیم بیشتر انیمیشن ها است:
419421

420-
Here's the helper `animate` function to setup most animations:
421422

422423
```js
423424
function animate({timing, draw, duration}) {
@@ -442,14 +443,14 @@ function animate({timing, draw, duration}) {
442443
}
443444
```
444445

445-
Options:
446+
گزینه ها:
446447

447-
- `duration` -- the total animation time in ms.
448-
- `timing` -- the function to calculate animation progress. Gets a time fraction from 0 to 1, returns the animation progress, usually from 0 to 1.
449-
- `draw` -- the function to draw the animation.
448+
- `مدت` -- کل زمان انیمیشن بر حسب ms.
449+
- `زمان بندی` -- تابعی برای محاسبه پیشرفت انیمیشن. کسر زمانی را از 0 تا 1 دریافت می کند، پیشرفت انیمیشن را معمولاً از 0 به 1 برمی گرداند.
450+
- `draw` -- تابعی برای ترسیم انیمیشن.
450451

451-
Surely we could improve it, add more bells and whistles, but JavaScript animations are not applied on a daily basis. They are used to do something interesting and non-standard. So you'd want to add the features that you need when you need them.
452+
مطمئناً می‌توانیم آن را بهبود بخشیم، زنگ‌ها و سوت‌های بیشتری اضافه کنیم، اما انیمیشن‌های جاوا اسکریپت به صورت روزانه اعمال نمی‌شوند. از آنها برای انجام کارهای جالب و غیر استاندارد استفاده می شود. بنابراین شما می خواهید ویژگی های مورد نیاز خود را در صورت نیاز اضافه کنید.
452453

453-
JavaScript animations can use any timing function. We covered a lot of examples and transformations to make them even more versatile. Unlike CSS, we are not limited to Bezier curves here.
454+
انیمیشن های جاوا اسکریپت می توانند از هر تابع زمان بندی استفاده کنند. ما نمونه ها و دگرگونی های زیادی را پوشش دادیم تا همه کاره تر شوند. برخلاف CSS، ما در اینجا به منحنی های Bezier محدود نمی شویم.
454455

455-
The same is about `draw`: we can animate anything, not just CSS properties.
456+
در مورد `draw` هم همینطور است: ما می توانیم هر چیزی را متحرک کنیم، نه فقط ویژگی های CSS.

0 commit comments

Comments
 (0)