Skip to content

Commit 8c22dd7

Browse files
authored
Update article.md
1 parent 4f2d5e2 commit 8c22dd7

1 file changed

Lines changed: 62 additions & 69 deletions

File tree

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

Lines changed: 62 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,24 @@ growing.onclick = function() {
7474

7575
## transition-property
7676

77-
In `transition-property`, we write a list of properties to animate, for instance: `left`, `margin-left`, `height`, `color`. Or we could write `all`, which means "animate all properties".
77+
در «transition-property»، ما فهرستی از ویژگی‌ها را برای متحرک کردن می‌نویسیم، به‌عنوان مثال: `left`, `margin-left`, `height`, `color`. یا می‌توانیم `all` را بنویسیم که به معنای «animate به همه ویژگی‌ها» است.
7878

79-
Do note that, there are properties which can not be animated. However, [most of the generally used properties are animatable](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties).
79+
توجه داشته باشید که ویژگی هایی وجود دارد که نمی توان آنها را متحرک کرد. با این حال، [بیشتر ویژگی‌هایی که معمولاً مورد استفاده قرار می‌گیرند متحرک هستند](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties).
8080

81-
## transition-duration
81+
## مدت زمان انتقال
8282

83-
In `transition-duration` we can specify how long the animation should take. The time should be in [CSS time format](https://www.w3.org/TR/css3-values/#time): in seconds `s` or milliseconds `ms`.
83+
در 'transition-duration' می‌توانیم مشخص کنیم که انیمیشن چقدر طول می‌کشد. زمان باید در [قالب زمان CSS](https://www.w3.org/TR/css3-values/#time): بر حسب ثانیه یا میلی ثانیه «ms» باشد.
8484

8585
## transition-delay
8686

87-
In `transition-delay` we can specify the delay *before* the animation. For instance, if `transition-delay` is `1s` and `transition-duration` is `2s`, then the animation starts 1 second after the property change and the total duration will be 2 seconds.
87+
در `transition-delay` می‌توانیم تاخیر *قبل از* انیمیشن را مشخص کنیم. برای مثال، اگر `تاخیر انتقال` `1 ثانیه` و `مدت انتقال` `2 ثانیه` باشد، انیمیشن 1 ثانیه پس از تغییر ویژگی شروع می‌شود و مدت زمان کل 2 ثانیه خواهد بود.
8888

89-
Negative values are also possible. Then the animation is shown immediately, but the starting point of the animation will be after given value (time). For example, if `transition-delay` is `-1s` and `transition-duration` is `2s`, then animation starts from the halfway point and total duration will be 1 second.
90-
91-
Here the animation shifts numbers from `0` to `9` using CSS `translate` property:
89+
مقادیر منفی نیز ممکن است. سپس انیمیشن بلافاصله نشان داده می شود، اما نقطه شروع انیمیشن پس از مقدار داده شده (زمان) خواهد بود. به عنوان مثال، اگر `تاخیر انتقال` `-۱ ثانیه` و `مدت انتقال` `۲ ثانیه` باشد، انیمیشن از نیمه شروع می‌شود و مدت زمان کل ۱ ثانیه خواهد بود.
9290

91+
در اینجا انیمیشن با استفاده از ویژگی `translate` CSS اعداد را از `0` به `9` تغییر می‌دهد:
9392
[codetabs src="digits"]
9493

95-
The `transform` property is animated like this:
96-
94+
ویژگی `transform` به شکل زیر متحرک است:
9795
```css
9896
#stripe.animate {
9997
transform: translate(-90%);
@@ -102,19 +100,18 @@ The `transform` property is animated like this:
102100
}
103101
```
104102

105-
In the example above JavaScript adds the class `.animate` to the element -- and the animation starts:
103+
در مثال بالا جاوا اسکریپت کلاس `.animate` را به عنصر اضافه می کند -- و انیمیشن شروع می شود:
106104

107105
```js
108106
stripe.classList.add('animate');
109107
```
110108

111-
We could also start it from somewhere in the middle of the transition, from an exact number, e.g. corresponding to the current second, using a negative `transition-delay`.
112-
113-
Here if you click the digit -- it starts the animation from the current second:
109+
ما همچنین می‌توانیم آن را از جایی در میانه انتقال، از یک عدد دقیق شروع کنیم، به عنوان مثال. متناظر با ثانیه فعلی، با استفاده از `transition-delay` منفی.
114110

111+
در اینجا اگر روی رقم کلیک کنید -- انیمیشن را از ثانیه فعلی شروع می کند:
115112
[codetabs src="digits-negative-delay"]
116113

117-
JavaScript does it with an extra line:
114+
جاوا اسکریپت این کار را با یک خط اضافی انجام می دهد:
118115

119116
```js
120117
stripe.onclick = function() {
@@ -127,43 +124,40 @@ stripe.onclick = function() {
127124
};
128125
```
129126

130-
## transition-timing-function
131-
132-
The timing function describes how the animation process is distributed along its timeline. Will it start slowly and then go fast, or vice versa.
127+
## تابع انتقال-زمان
133128

134-
It appears to be the most complicated property at first. But it becomes very simple if we devote a bit time to it.
129+
تابع زمان بندی نحوه توزیع فرآیند انیمیشن در طول جدول زمانی آن را توصیف می کند. آیا به آرامی شروع می شود و سپس سریع می رود یا برعکس.
135130

136-
That property accepts two kinds of values: a Bezier curve or steps. Let's start with the curve, as it's used more often.
131+
به نظر می رسد در ابتدا پیچیده ترین ویژگی باشد. اما اگر کمی زمان را به آن اختصاص دهیم بسیار ساده می شود.
137132

138-
### Bezier curve
133+
این ویژگی دو نوع مقدار را می پذیرد: منحنی Bezier یا مراحل. بیایید با منحنی شروع کنیم، زیرا بیشتر استفاده می شود.
139134

140-
The timing function can be set as a [Bezier curve](/bezier-curve) with 4 control points that satisfy the conditions:
135+
### Bezier منحنی
141136

142-
1. First control point: `(0,0)`.
143-
2. Last control point: `(1,1)`.
144-
3. For intermediate points, the values of `x` must be in the interval `0..1`, `y` can be anything.
137+
تابع زمان بندی را می توان به عنوان یک [منحنی Bezier](/bezier-curve) با 4 نقطه کنترل که شرایط را برآورده می کند تنظیم کرد:
138+
1. اولین نقطه کنترل: `(0,0)`.
139+
2. آخرین نقطه کنترل: `(1,1)`.
140+
3. برای نقاط میانی، مقادیر `x` باید در بازه `0..1` باشد، `y` می تواند هر چیزی باشد.
145141

146-
The syntax for a Bezier curve in CSS: `cubic-bezier(x2, y2, x3, y3)`. Here we need to specify only 2nd and 3rd control points, because the 1st one is fixed to `(0,0)` and the 4th one is `(1,1)`.
142+
نحو برای منحنی Bezier در `CSS: cubic-bezier(x2، y2، x3، y3)`. در اینجا باید فقط نقاط کنترل 2 و 3 را مشخص کنیم، زیرا اولین نقطه روی `(0,0)` ثابت شده است و نقطه چهارم `(1،1)` است.
147143

148-
The timing function describes how fast the animation process goes.
144+
تابع زمان بندی سرعت فرآیند انیمیشن را توصیف می کند.
149145

150-
- The `x` axis is the time: `0` -- the start, `1` -- the end of `transition-duration`.
151-
- The `y` axis specifies the completion of the process: `0` -- the starting value of the property, `1` -- the final value.
146+
- محور `x` زمان است: `0` -- شروع، `1` -- پایان `transition-duration`.
147+
- محور `y` تکمیل فرآیند را مشخص می کند: `0` -- مقدار شروع ویژگی، `1` -- مقدار نهایی.
152148

153-
The simplest variant is when the animation goes uniformly, with the same linear speed. That can be specified by the curve `cubic-bezier(0, 0, 1, 1)`.
149+
ساده ترین حالت زمانی است که انیمیشن به طور یکنواخت و با همان سرعت خطی پیش می رود. این را می توان با منحنی `cubic-bezier(0، 0، 1، 1)` مشخص کرد.
154150

155-
Here's how that curve looks:
151+
در اینجا این منحنی به نظر می رسد:
156152

157153
![](bezier-linear.svg)
158154

159-
...As we can see, it's just a straight line. As the time (`x`) passes, the completion (`y`) of the animation steadily goes from `0` to `1`.
160-
161-
The train in the example below goes from left to right with the permanent speed (click it):
155+
... همانطور که می بینیم، فقط یک خط مستقیم است. با گذشت زمان (`x`)، تکمیل (`y`) انیمیشن به طور پیوسته از 0 به 1 می رود.
162156

157+
قطار در مثال زیر از چپ به راست با سرعت دائمی حرکت می کند (روی آن کلیک کنید):
163158
[codetabs src="train-linear"]
164159

165-
The CSS `transition` is based on that curve:
166-
160+
`انتقال` CSS بر اساس آن منحنی است:
167161
```css
168162
.train {
169163
left: 0;
@@ -172,18 +166,17 @@ The CSS `transition` is based on that curve:
172166
}
173167
```
174168

175-
...And how can we show a train slowing down?
169+
... و چگونه می توانیم قطاری را در حال کاهش سرعت نشان دهیم؟
176170

177-
We can use another Bezier curve: `cubic-bezier(0.0, 0.5, 0.5 ,1.0)`.
171+
می‌توانیم از منحنی دیگر Bezier استفاده کنیم: `cubic-bezier(0.0، 0.5، 0.5، 1.0)`.
178172

179-
The graph:
173+
نمودار:
180174

181175
![](train-curve.svg)
182176

183-
As we can see, the process starts fast: the curve soars up high, and then slower and slower.
184-
185-
Here's the timing function in action (click the train):
177+
همانطور که می بینیم، این روند سریع شروع می شود: منحنی به اوج می رسد و سپس کندتر و کندتر می شود.
186178

179+
در اینجا تابع زمان بندی در عمل آمده است (روی train کلیک کنید):
187180
[codetabs src="train"]
188181

189182
CSS:
@@ -195,20 +188,21 @@ CSS:
195188
}
196189
```
197190

198-
There are several built-in curves: `linear`, `ease`, `ease-in`, `ease-out` and `ease-in-out`.
191+
چندین منحنی داخلی وجود دارد: `linear`, `ease`, `ease-in`, `ease-out` و `ease-in-out`.
192+
.
199193

200-
The `linear` is a shorthand for `cubic-bezier(0, 0, 1, 1)` -- a straight line, which we described above.
194+
`linear` مخفف `cubic-bezier(0، 0، 1، 1)` است - یک خط مستقیم، که در بالا توضیح دادیم.
201195

202-
Other names are shorthands for the following `cubic-bezier`:
196+
نام‌های دیگر مخفف عبارت `cubic-bezier` زیر هستند:
203197

204198
| <code>ease</code><sup>*</sup> | <code>ease-in</code> | <code>ease-out</code> | <code>ease-in-out</code> |
205199
|-------------------------------|----------------------|-----------------------|--------------------------|
206200
| <code>(0.25, 0.1, 0.25, 1.0)</code> | <code>(0.42, 0, 1.0, 1.0)</code> | <code>(0, 0, 0.58, 1.0)</code> | <code>(0.42, 0, 0.58, 1.0)</code> |
207201
| ![ease, figure](ease.svg) | ![ease-in, figure](ease-in.svg) | ![ease-out, figure](ease-out.svg) | ![ease-in-out, figure](ease-in-out.svg) |
208202

209-
`*` -- by default, if there's no timing function, `ease` is used.
203+
`*` -- به‌طور پیش‌فرض، اگر تابع زمان‌بندی وجود نداشته باشد، `ease` استفاده می‌شود.
210204

211-
So we could use `ease-out` for our slowing down train:
205+
بنابراین می‌توانیم از `ease-out` برای کاهش سرعت قطار خود استفاده کنیم:
212206

213207
```css
214208
.train {
@@ -218,13 +212,13 @@ So we could use `ease-out` for our slowing down train:
218212
}
219213
```
220214

221-
But it looks a bit differently.
215+
اما کمی متفاوت به نظر می رسد.
222216

223-
**A Bezier curve can make the animation exceed its range.**
217+
**یک منحنی Bezier می تواند باعث شود که انیمیشن از محدوده خود فراتر رود.**
224218

225-
The control points on the curve can have any `y` coordinates: even negative or huge ones. Then the Bezier curve would also extend very low or high, making the animation go beyond its normal range.
219+
نقاط کنترل روی منحنی می توانند هر مختصات `y` داشته باشند: حتی منفی یا بزرگ. سپس منحنی Bezier نیز بسیار کم یا زیاد می شود و باعث می شود انیمیشن از محدوده طبیعی خود فراتر رود.
226220

227-
In the example below the animation code is:
221+
در مثال زیر کد انیمیشن به شرح زیر است:
228222

229223
```css
230224
.train {
@@ -234,37 +228,36 @@ In the example below the animation code is:
234228
}
235229
```
236230

237-
The property `left` should animate from `100px` to `400px`.
238-
239-
But if you click the train, you'll see that:
231+
ویژگی "چپ" باید از `100px` تا `400px` متحرک شود.
240232

241-
- First, the train goes *back*: `left` becomes less than `100px`.
242-
- Then it goes forward, a little bit farther than `400px`.
243-
- And then back again -- to `400px`.
233+
اما اگر روی قطار کلیک کنید، خواهید دید که:
244234

235+
- ابتدا، قطار *به عقب* می رود: «چپ» کمتر از `100px` می شود.
236+
- سپس به جلو می رود، کمی دورتر از `400px`.
237+
- و سپس دوباره -- به `400px`.
245238
[codetabs src="train-over"]
246239

247-
Why it happens is pretty obvious if we look at the graph of the given Bezier curve:
240+
اگر به نمودار منحنی Bezier داده شده نگاه کنیم، چرا این اتفاق می افتد کاملاً واضح است:
248241

249242
![](bezier-train-over.svg)
250243

251-
We moved the `y` coordinate of the 2nd point below zero, and for the 3rd point we made it over `1`, so the curve goes out of the "regular" quadrant. The `y` is out of the "standard" range `0..1`.
244+
مختصات `y` نقطه دوم را به زیر صفر رساندیم و برای نقطه سوم آن را روی `1` قرار دادیم، بنابراین منحنی از ربع `منظم` خارج می‌شود. `y` خارج از محدوده `استاندارد` `0..1` است.
252245

253-
As we know, `y` measures "the completion of the animation process". The value `y = 0` corresponds to the starting property value and `y = 1` -- the ending value. So values `y<0` move the property beyond the starting `left` and `y>1` -- past the final `left`.
246+
همانطور که می دانیم، `y` "تکمیل فرآیند انیمیشن" را اندازه گیری می کند. مقدار "y = 0" مربوط به مقدار ویژگی شروع و `y = 1` - مقدار پایانی است. بنابراین مقادیر `y<0` ویژگی را فراتر از `چپ` شروع و `y>1` - از `چپ` نهایی عبور می‌کند.
254247

255-
That's a "soft" variant for sure. If we put `y` values like `-99` and `99` then the train would jump out of the range much more.
248+
مطمئناً این یک نوع "نرم" است. اگر مقادیر `y` مانند `-99` و «99» را قرار دهیم، قطار بسیار بیشتر از محدوده خارج خواهد شد.
256249

257-
But how do we make a Bezier curve for a specific task? There are many tools.
250+
اما چگونه یک منحنی Bezier برای یک کار خاص بسازیم؟ ابزارهای زیادی وجود دارد.
258251

259-
- For instance, we can do it on the site <https://cubic-bezier.com>.
260-
- Browser developer tools also have special support for Bezier curves in CSS:
261-
1. Open the developer tools with `key:F12` (Mac: `key:Cmd+Opt+I`).
262-
2. Select the `Elements` tab, then pay attention to the `Styles` sub-panel at the right side.
263-
3. CSS properties with a word `cubic-bezier` will have an icon before this word.
264-
4. Click this icon to edit the curve.
252+
- به عنوان مثال، ما می توانیم این کار را در سایت <https://cubic-bezier.com> انجام دهیم.
253+
- ابزارهای توسعه دهنده مرورگر همچنین از منحنی های Bezier در CSS پشتیبانی می کنند:
254+
1. ابزارهای توسعه دهنده را با `key:F12` باز کنید (`Mac: key:Cmd+Opt+I`).
255+
2. برگه `Elements` را انتخاب کنید، سپس به پنل فرعی `Styles` در سمت راست توجه کنید.
256+
3. ویژگی های CSS با کلمه `cubic-bezier` یک نماد قبل از این کلمه خواهد داشت.
257+
4. برای ویرایش منحنی روی این نماد کلیک کنید.
265258

266259

267-
### Steps
260+
### مراحل
268261

269262
The timing function `steps(number of steps[, start/end])` allows splitting an transition into multiple steps.
270263

0 commit comments

Comments
 (0)