Skip to content

Commit 5abbf35

Browse files
authored
line 310
1 parent 03b1098 commit 5abbf35

1 file changed

Lines changed: 41 additions & 46 deletions

File tree

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

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ function animate({timing, draw, duration}) {
143143
}
144144
```
145145

146-
Function `animate` accepts 3 parameters that essentially describes the animation:
146+
تابع animate` 3` پارامتر را می پذیرد که اساساً انیمیشن را توصیف می کند:
147147

148148
`duration`
149-
: Total time of animation. Like, `1000`.
149+
: زمان کل انیمیشن. مانند `1000`.
150150

151-
`timing(timeFraction)`
152-
: Timing function, like CSS-property `transition-timing-function` that gets the fraction of time that passed (`0` at start, `1` at the end) and returns the animation completion (like `y` on the Bezier curve).
151+
`زمان بندی (زمان کسر)`.
152+
: تابع زمان بندی، مانند ویژگی `CSS `transition-timing-function که کسری از زمان سپری شده را دریافت می کند ('0' در شروع، '1' در پایان) و تکمیل انیمیشن را برمی گرداند (مانند `y` در Bezier منحنی).
153153

154-
For instance, a linear function means that the animation goes on uniformly with the same speed:
154+
به عنوان مثال، یک تابع خطی به این معنی است که انیمیشن به طور یکنواخت با همان سرعت ادامه می یابد:
155155

156156
```js
157157
function linear(timeFraction) {
@@ -162,30 +162,28 @@ Function `animate` accepts 3 parameters that essentially describes the animation
162162
Its graph:
163163
![](linear.svg)
164164

165-
That's just like `transition-timing-function: linear`. There are more interesting variants shown below.
165+
این دقیقاً مانند تابع `Transition-timing-function: خطی` است. انواع جالب تری وجود دارد که در زیر نشان داده شده است.
166166

167167
`draw(progress)`
168-
: The function that takes the animation completion state and draws it. The value `progress=0` denotes the beginning animation state, and `progress=1` -- the end state.
168+
: تابعی که حالت تکمیل انیمیشن را می گیرد و آن را ترسیم می کند. مقدار `پیشرفت=0` نشان‌دهنده وضعیت شروع انیمیشن، و `پیشرفت=1` -- حالت پایان است.
169169

170-
This is that function that actually draws out the animation.
170+
این همان تابعی است که در واقع انیمیشن را بیرون می کشد.
171171

172-
It can move the element:
172+
می تواند عنصر را جابجا کند:
173173
```js
174174
function draw(progress) {
175175
train.style.left = progress + 'px';
176176
}
177177
```
178178

179-
...Or do anything else, we can animate anything, in any way.
179+
... یا هر کار دیگری انجام دهیم، ما می توانیم هر چیزی را به هر شکلی متحرک کنیم.
180180

181+
بیایید با استفاده از تابع خود عنصر `width` را از `0` به `100٪` متحرک کنیم.
181182

182-
Let's animate the element `width` from `0` to `100%` using our function.
183-
184-
Click on the element for the demo:
185-
183+
روی عنصر برای دمو کلیک کنید:
186184
[codetabs height=60 src="width"]
187185

188-
The code for it:
186+
کد نمونه:
189187

190188
```js
191189
animate({
@@ -199,87 +197,84 @@ animate({
199197
});
200198
```
201199

202-
Unlike CSS animation, we can make any timing function and any drawing function here. The timing function is not limited by Bezier curves. And `draw` can go beyond properties, create new elements for like fireworks animation or something.
200+
برخلاف انیمیشن CSS، ما می توانیم هر تابع زمان بندی و هر تابع ترسیمی را در اینجا ایجاد کنیم. عملکرد زمان بندی توسط منحنی های Bezier محدود نمی شود. و `draw` می‌تواند فراتر از ویژگی‌ها باشد، عناصر جدیدی مانند انیمیشن آتش‌بازی یا چیز دیگری ایجاد کند.
203201

204-
## Timing functions
202+
## Timing تابع
205203

206-
We saw the simplest, linear timing function above.
204+
ما ساده ترین تابع زمان بندی خطی را در بالا دیدیم.
207205

208-
Let's see more of them. We'll try movement animations with different timing functions to see how they work.
206+
بیایید بیشتر آنها را ببینیم. ما انیمیشن های حرکتی را با عملکردهای زمان بندی مختلف امتحان می کنیم تا ببینیم چگونه کار می کنند.
209207

210-
### Power of n
208+
### توان برای n
211209

212-
If we want to speed up the animation, we can use `progress` in the power `n`.
210+
اگر بخواهیم سرعت انیمیشن را افزایش دهیم، می‌توانیم از `پیشرفت` در قدرت `n` استفاده کنیم.
213211

214-
For instance, a parabolic curve:
212+
به عنوان مثال، منحنی سهموی:
215213

216214
```js
217215
function quad(timeFraction) {
218216
return Math.pow(timeFraction, 2)
219217
}
220218
```
221219

222-
The graph:
220+
گراف:
223221

224222
![](quad.svg)
225223

226-
See in action (click to activate):
224+
برای دیدن کلیک کنید:
227225

228226
[iframe height=40 src="quad" link]
229227

230-
...Or the cubic curve or even greater `n`. Increasing the power makes it speed up faster.
228+
... یا منحنی مکعب یا حتی `n` بزرگتر. افزایش قدرت باعث افزایش سرعت آن می شود.
231229

232-
Here's the graph for `progress` in the power `5`:
230+
در اینجا نمودار `پیشرفت` در توان `5` آمده است:
233231

234232
![](quint.svg)
235233

236-
In action:
234+
در عمل:
237235

238236
[iframe height=40 src="quint" link]
239237

240-
### The arc
238+
### قوس یا The arc
241239

242-
Function:
240+
تابع:
243241

244242
```js
245243
function circ(timeFraction) {
246244
return 1 - Math.sin(Math.acos(timeFraction));
247245
}
248246
```
249247

250-
The graph:
248+
گراف:
251249

252250
![](circ.svg)
253251

254252
[iframe height=40 src="circ" link]
255253

256-
### Back: bow shooting
254+
### Back: تیر اندازی با کمان
257255

258-
This function does the "bow shooting". First we "pull the bowstring", and then "shoot".
256+
این تابع `تیراندازی با کمان` را انجام می دهد. ابتدا سیم کمان را می کشیم و سپس شلیک می کنیم.
259257

260-
Unlike previous functions, it depends on an additional parameter `x`, the "elasticity coefficient". The distance of "bowstring pulling" is defined by it.
261-
262-
The code:
258+
برخلاف توابع قبلی، به یک پارامتر اضافی `x`، `ضریب الاستیسیته` بستگی دارد. فاصله `کشیدن ریسمان کمان` با آن مشخص می شود.
263259

264260
```js
265261
function back(x, timeFraction) {
266262
return Math.pow(timeFraction, 2) * ((x + 1) * timeFraction - x)
267263
}
268264
```
269265

270-
**The graph for `x = 1.5`:**
266+
**گراف برای `x = 1.5`:**
271267

272268
![](back.svg)
273269

274-
For animation we use it with a specific value of `x`. Example for `x = 1.5`:
275-
270+
برای انیمیشن از آن با مقدار خاصی از `x` استفاده می کنیم. مثال برای `x = 1.5`:
276271
[iframe height=40 src="back" link]
277272

278-
### Bounce
273+
### پرش یا Bounce
279274

280-
Imagine we are dropping a ball. It falls down, then bounces back a few times and stops.
275+
تصور کنید در حال رها کردن یک توپ هستیم. سقوط می کند، سپس چند بار به عقب برگشته و می ایستد.
281276

282-
The `bounce` function does the same, but in the reverse order: "bouncing" starts immediately. It uses few special coefficients for that:
277+
تابع `جهش` همین کار را می کند، اما به ترتیب معکوس: `جهش` بلافاصله شروع می شود. از چند ضرایب خاص برای آن استفاده می کند:
283278

284279
```js
285280
function bounce(timeFraction) {
@@ -291,24 +286,24 @@ function bounce(timeFraction) {
291286
}
292287
```
293288

294-
In action:
289+
در عمل:
295290

296291
[iframe height=40 src="bounce" link]
297292

298-
### Elastic animation
293+
### Elastic انیمیشن
299294

300-
One more "elastic" function that accepts an additional parameter `x` for the "initial range".
295+
یک تابع `الاستیک` دیگر که یک پارامتر اضافی `x` را برای `محدوده اولیه` می پذیرد.
301296

302297
```js
303298
function elastic(x, timeFraction) {
304299
return Math.pow(2, 10 * (timeFraction - 1)) * Math.cos(20 * Math.PI * x / 3 * timeFraction)
305300
}
306301
```
307302

308-
**The graph for `x=1.5`:**
303+
**گراف برای `x=1.5`:**
309304
![](elastic.svg)
310305

311-
In action for `x=1.5`:
306+
در عمل برای `x=1.5`:
312307

313308
[iframe height=40 src="elastic" link]
314309

0 commit comments

Comments
 (0)