Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 7-animation/3-js-animation/1-animate-ball/solution.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
To bounce we can use CSS property `top` and `position:absolute` for the ball inside the field with `position:relative`.
곡을 νŠ€μ–΄ 였λ₯΄κ²Œ ν•˜κΈ° μœ„ν•΄μ„œλŠ” κ³΅μ—λŠ” CSS ν”„λ‘œνΌν‹°μΈ `top`κ³Ό `position:absolute`λ₯Ό, 곡이 λ“€μ–΄μžˆλŠ” ν•„λ“œμ—λŠ”`position:relative`λ₯Ό μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

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.
ν•„λ“œμ˜ μ•„λž˜μͺ½ μ’Œν‘œλŠ” `field.clientHeight`μž…λ‹ˆλ‹€. `top` ν”„λ‘œνΌν‹°λŠ” 곡의 μœ„μͺ½ λͺ¨μ„œλ¦¬λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ―€λ‘œ 곡의 μœ„μͺ½ λͺ¨μ„œλ¦¬λŠ” `0`λΆ€ν„° κ·Έ μœ„μΉ˜μ˜ μ΅œμ†Ÿκ°’μΈ `field.clientHeight - ball.clientHeight`κΉŒμ§€ μ›€μ§μž…λ‹ˆλ‹€.

To to get the "bouncing" effect we can use the timing function `bounce` in `easeOut` mode.
νŠ€μ–΄ 였λ₯΄λŠ” μ• λ‹ˆλ©”μ΄μ…˜ 효과λ₯Ό μ μš©ν•˜κΈ° μœ„ν•΄ `easeOut`λͺ¨λ“œμ—μ„œ timing ν•¨μˆ˜ `bounce`λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€.

Here's the final code for the animation:
λ‹€μŒμ€ μ• λ‹ˆλ©”μ΄μ…˜ 효과λ₯Ό μ μš©ν•œ μ΅œμ’… μ½”λ“œμž…λ‹ˆλ‹€.

```js
let to = field.clientHeight - ball.clientHeight;
Expand Down
4 changes: 2 additions & 2 deletions 7-animation/3-js-animation/1-animate-ball/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ importance: 5

---

# Animate the bouncing ball
# 곡에 νŠ€μ–΄ 였λ₯΄λŠ” μ• λ‹ˆλ©”μ΄μ…˜ 효과 μ£ΌκΈ°

Make a bouncing ball. Click to see how it should look:
νŠ€μ–΄ 였λ₯΄λŠ” 곡을 λ§Œλ“€μ–΄λ΄…μ‹œλ‹€. μ• λ‹ˆλ©”μ΄μ…˜μ΄ μ–΄λ–»κ²Œ μ μš©λ˜μ–΄μ•Ό ν•˜λŠ”μ§€ 보렀면 ν΄λ¦­ν•΄λ³΄μ„Έμš”.

[iframe height=250 src="solution"]
10 changes: 5 additions & 5 deletions 7-animation/3-js-animation/2-animate-ball-hops/solution.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
In the task <info:task/animate-ball> we had only one property to animate. Now we need one more: `elem.style.left`.
<info:task/animate-ball> κ³Όμ œμ—μ„œλŠ” μ• λ‹ˆλ©”μ΄μ…˜ 효과λ₯Ό μ£ΌλŠ” ν”„λ‘œνΌν‹°κ°€ 였직 ν•œκ°œ μ‘΄μž¬ν–ˆμŠ΅λ‹ˆλ‹€. 이제 `elem.style.left`λΌλŠ” ν•˜λ‚˜μ˜ ν”„λ‘œνΌν‹°κ°€ 더 ν•„μš”ν•©λ‹ˆλ‹€.

The horizontal coordinate changes by another law: it does not "bounce", but gradually increases shifting the ball to the right.
νŠ€μ–΄ 였λ₯΄μ§€ μ•Šμ§€λ§Œ 곡이 μ„œμ„œνžˆ 였λ₯Έμͺ½μœΌλ‘œ μ΄λ™ν•˜λŠ” 또 λ‹€λ₯Έ κ·œμΉ™μ— μ˜ν•΄ μˆ˜ν‰μ’Œν‘œκ°€ λ°”λ€λ‹ˆλ‹€.

We can write one more `animate` for it.
였λ₯Έμͺ½μœΌλ‘œ μ›€μ§μ΄λŠ” 것을 μœ„ν•œ `animate`λ₯Ό ν•˜λ‚˜ 더 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

As the time function we could use `linear`, but something like `makeEaseOut(quad)` looks much better.
time function으둜 `linear`을 μ‚¬μš©ν•  수 μžˆμ§€λ§Œ `makeEaseOut(quad)`같은 것을 μ‚¬μš©ν•˜λŠ”κ²Œ 더 쒋을 것 κ°™μŠ΅λ‹ˆλ‹€.

The code:
μ½”λ“œλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

```js
let height = field.clientHeight - ball.clientHeight;
Expand Down
8 changes: 4 additions & 4 deletions 7-animation/3-js-animation/2-animate-ball-hops/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ importance: 5

---

# Animate the ball bouncing to the right
# 곡을 였λ₯Έμͺ½μœΌλ‘œ νŠ€μ–΄ 였λ₯΄κ²Œν•˜λŠ” μ• λ‹ˆλ©”μ΄μ…˜ 효과 μ£ΌκΈ°

Make the ball bounce to the right. Like this:
λ‹€μŒκ³Ό 같이 곡이 였λ₯Έμͺ½μœΌλ‘œ νŠ€μ–΄ 였λ₯΄κ²Œ ν•΄λ΄…μ‹œλ‹€.

[iframe height=250 src="solution"]

Write the animation code. The distance to the left is `100px`.
μ• λ‹ˆλ©”μ΄μ…˜ μ½”λ“œλ₯Ό μž‘μ„±ν•΄λ³΄μ„Έμš”. μ™Όμͺ½μœΌλ‘œλΆ€ν„° κ±°λ¦¬λŠ” `100px`μž…λ‹ˆλ‹€.

Take the solution of the previous task <info:task/animate-ball> as the source.
이전 과제 <info:task/animate-ball>의 해닡을 μ°Έκ³ ν•΄λ³΄μ„Έμš”.