Skip to content

Commit 4bc5f67

Browse files
Merge pull request #179 from nglazov/7-animation/3-js-animation
7-animation/3-js-animation
2 parents 6e80c6c + b3cbae9 commit 4bc5f67

File tree

7 files changed

+151
-154
lines changed

7 files changed

+151
-154
lines changed

7-animation/3-js-animation/1-animate-ball/solution.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
To bounce we can use CSS property `top` and `position:absolute` for the ball inside the field with `position:relative`.
1+
Чтобы заставить мячик прыгать, можно использовать CSS-свойство `top` и задать мячику `position:absolute` внутри поля с `position:relative`.
22

3-
The bottom coordinate of the field is `field.clientHeight`. But the `top` property gives coordinates for the top of the ball, the edge position is `field.clientHeight - ball.clientHeight`.
3+
Нижняя координата поля -- `field.clientHeight`. CSS-свойство `top` относится к верхней границе мяча, которая должна идти от 0 до `field.clientHeight - ball.clientHeight`.
44

5-
So we animate the `top` from `0` to `field.clientHeight - ball.clientHeight`.
5+
А чтобы получить эффект "скачущего" мяча, мы можем использовать функцию расчета времени `bounce` в режиме `easeOut`.
66

7-
Now to get the "bouncing" effect we can use the timing function `bounce` in `easeOut` mode.
8-
9-
Here's the final code for the animation:
7+
Вот конечный код для анимации:
108

119
```js
1210
let to = field.clientHeight - ball.clientHeight;

7-animation/3-js-animation/1-animate-ball/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ importance: 5
22

33
---
44

5-
# Animate the bouncing ball
5+
# Анимируйте прыгающий мячик
66

7-
Make a bouncing ball. Click to see how it should look:
7+
Создайте прыгающий мячик. Кликните, чтобы посмотреть, как это должно выглядеть:
88

99
[iframe height=250 src="solution"]

7-animation/3-js-animation/2-animate-ball-hops/solution.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
In the task <info:task/animate-ball> we had only one property to animate. Now we need one more: `elem.style.left`.
1+
В задаче <info:task/animate-ball> нам надо было анимировать только одно свойство. Теперь необходимо добавить еще одно: `elem.style.left`.
22

3-
The horizontal coordinate changes by another law: it does not "bounce", but gradually increases shifting the ball to the right.
3+
Горизонтальная координата меняется по другому закону: она не «подпрыгивает», а постепенно увеличивается, сдвигая шар вправо.
44

5-
We can write one more `animate` for it.
5+
Для этого мы можем написать еще одну функцию `animate`.
66

7-
As the time function we could use `linear`, but something like `makeEaseOut(quad)` looks much better.
7+
В качестве временной функции можно использовать `linear`, но `makeEaseOut(quad)` будет выглядеть гораздо лучше.
88

9-
The code:
9+
Код:
1010

1111
```js
1212
let height = field.clientHeight - ball.clientHeight;
1313
let width = 100;
1414

15-
// animate top (bouncing)
15+
// анимация top (прыжки)
1616
animate({
1717
duration: 2000,
1818
timing: makeEaseOut(bounce),
@@ -21,7 +21,7 @@ animate({
2121
}
2222
});
2323

24-
// animate left (moving to the right)
24+
// анимация left (движение вправо)
2525
animate({
2626
duration: 2000,
2727
timing: makeEaseOut(quad),

7-animation/3-js-animation/2-animate-ball-hops/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ importance: 5
22

33
---
44

5-
# Animate the ball bouncing to the right
5+
# Анимируйте мячик, прыгающий вправо
66

7-
Make the ball bounce to the right. Like this:
7+
Сделайте отскок мяча вправо. Как в примере:
88

99
[iframe height=250 src="solution"]
1010

11-
Write the animation code. The distance to the left is `100px`.
11+
Напишите код для анимации. Расстояние слева `100px`.
1212

13-
Take the solution of the previous task <info:task/animate-ball> as the source.
13+
Возьмите решение предыдущей задачи <info:task/animate-ball> за основу.

0 commit comments

Comments
 (0)