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/3-js-animation/article.md
+41-46Lines changed: 41 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,15 +143,15 @@ function animate({timing, draw, duration}) {
143
143
}
144
144
```
145
145
146
-
Function `animate`accepts 3 parameters that essentially describes the animation:
146
+
تابع animate`3` پارامتر را می پذیرد که اساساً انیمیشن را توصیف می کند:
147
147
148
148
`duration`
149
-
: Total time of animation. Like,`1000`.
149
+
: زمان کل انیمیشن. مانند`1000`.
150
150
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 منحنی).
153
153
154
-
For instance, a linear function means that the animation goes on uniformly with the same speed:
154
+
به عنوان مثال، یک تابع خطی به این معنی است که انیمیشن به طور یکنواخت با همان سرعت ادامه می یابد:
155
155
156
156
```js
157
157
function linear(timeFraction) {
@@ -162,30 +162,28 @@ Function `animate` accepts 3 parameters that essentially describes the animation
162
162
Its graph:
163
163

164
164
165
-
That's just like `transition-timing-function: linear`. There are more interesting variants shown below.
165
+
این دقیقاً مانند تابع `Transition-timing-function: خطی` است. انواع جالب تری وجود دارد که در زیر نشان داده شده است.
166
166
167
167
`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` -- حالت پایان است.
169
169
170
-
This is that function that actually draws out the animation.
170
+
این همان تابعی است که در واقع انیمیشن را بیرون می کشد.
171
171
172
-
It can move the element:
172
+
می تواند عنصر را جابجا کند:
173
173
```js
174
174
function draw(progress) {
175
175
train.style.left = progress + 'px';
176
176
}
177
177
```
178
178
179
-
...Or do anything else, we can animate anything, in any way.
179
+
... یا هر کار دیگری انجام دهیم، ما می توانیم هر چیزی را به هر شکلی متحرک کنیم.
180
180
181
+
بیایید با استفاده از تابع خود عنصر `width` را از `0` به `100٪` متحرک کنیم.
181
182
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
+
روی عنصر برای دمو کلیک کنید:
186
184
[codetabs height=60 src="width"]
187
185
188
-
The code for it:
186
+
کد نمونه:
189
187
190
188
```js
191
189
animate({
@@ -199,87 +197,84 @@ animate({
199
197
});
200
198
```
201
199
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`میتواند فراتر از ویژگیها باشد، عناصر جدیدی مانند انیمیشن آتشبازی یا چیز دیگری ایجاد کند.
203
201
204
-
## Timing functions
202
+
## Timing تابع
205
203
206
-
We saw the simplest, linear timing function above.
204
+
ما ساده ترین تابع زمان بندی خطی را در بالا دیدیم.
207
205
208
-
Let's see more of them. We'll try movement animations with different timing functions to see how they work.
206
+
بیایید بیشتر آنها را ببینیم. ما انیمیشن های حرکتی را با عملکردهای زمان بندی مختلف امتحان می کنیم تا ببینیم چگونه کار می کنند.
209
207
210
-
### Power of n
208
+
### توان برای n
211
209
212
-
If we want to speed up the animation, we can use `progress` in the power `n`.
210
+
اگر بخواهیم سرعت انیمیشن را افزایش دهیم، میتوانیم از `پیشرفت` در قدرت `n` استفاده کنیم.
213
211
214
-
For instance, a parabolic curve:
212
+
به عنوان مثال، منحنی سهموی:
215
213
216
214
```js
217
215
functionquad(timeFraction) {
218
216
returnMath.pow(timeFraction, 2)
219
217
}
220
218
```
221
219
222
-
The graph:
220
+
گراف:
223
221
224
222

225
223
226
-
See in action (click to activate):
224
+
برای دیدن کلیک کنید:
227
225
228
226
[iframe height=40 src="quad" link]
229
227
230
-
...Or the cubic curve or even greater `n`. Increasing the power makes it speed up faster.
228
+
... یا منحنی مکعب یا حتی `n` بزرگتر. افزایش قدرت باعث افزایش سرعت آن می شود.
231
229
232
-
Here's the graph for `progress` in the power `5`:
230
+
در اینجا نمودار `پیشرفت` در توان `5` آمده است:
233
231
234
232

235
233
236
-
In action:
234
+
در عمل:
237
235
238
236
[iframe height=40 src="quint" link]
239
237
240
-
### The arc
238
+
### قوس یا The arc
241
239
242
-
Function:
240
+
تابع:
243
241
244
242
```js
245
243
functioncirc(timeFraction) {
246
244
return1-Math.sin(Math.acos(timeFraction));
247
245
}
248
246
```
249
247
250
-
The graph:
248
+
گراف:
251
249
252
250

253
251
254
252
[iframe height=40 src="circ" link]
255
253
256
-
### Back: bow shooting
254
+
### Back: تیر اندازی با کمان
257
255
258
-
This function does the "bow shooting". First we "pull the bowstring", and then "shoot".
256
+
این تابع `تیراندازی با کمان` را انجام می دهد. ابتدا سیم کمان را می کشیم و سپس شلیک می کنیم.
259
257
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`، `ضریب الاستیسیته` بستگی دارد. فاصله `کشیدن ریسمان کمان` با آن مشخص می شود.
0 commit comments