Skip to content

Commit db32cd0

Browse files
committed
minor
1 parent cfff5c1 commit db32cd0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
To bounce we can use CSS property `top` and `position:absolute` for the ball inside the field with `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+
The bottom coordinate of the field is `field.clientHeight`. The CSS `top` property refers to the upper edge of the ball. So it should go from `0` till `field.clientHeight - ball.clientHeight`, that's the final lowest position of the upper edge of the ball.
44

5-
So we animate the `top` from `0` to `field.clientHeight - ball.clientHeight`.
6-
7-
Now to get the "bouncing" effect we can use the timing function `bounce` in `easeOut` mode.
5+
To to get the "bouncing" effect we can use the timing function `bounce` in `easeOut` mode.
86

97
Here's the final code for the animation:
108

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ setInterval(animate2, 20); // in different places of the script
7575
setInterval(animate3, 20);
7676
```
7777

78-
These several independent redraws should be grouped together, to make the redraw easier for the browser (and hence smoother for people).
78+
These several independent redraws should be grouped together, to make the redraw easier for the browser and hence load less CPU load and look smoother.
7979

8080
There's one more thing to keep in mind. Sometimes when CPU is overloaded, or there are other reasons to redraw less often (like when the browser tab is hidden), so we really shouldn't run it every `20ms`.
8181

0 commit comments

Comments
 (0)