Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JavaScript Animations#136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
karlasamantha wants to merge9 commits intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromkarlasamantha:javascript-animations
Open
Show file tree
Hide file tree
Changes fromall 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 deletions7-animation/3-js-animation/1-animate-ball/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
To bounce we can useCSSproperty`top`and `position:absolute`for the ball inside the field with `position:relative`.
Para quicar, podemos usar a propriedadeCSS `top`e `position:absolute`para a bola dentro do campo com `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.
A coordenada inferior do campo é`field.clientHeight`.Mas a propriedade`top`fornece coordenadas para o topo da bola Então animamos a propriedade `top` a partir de`0`até `field.clientHeight - ball.clientHeight`,isto é até à posição mais baixa do topo da bola.

To get the "bouncing" effect we can use the timing function`bounce`in`easeOut` mode.
Para obter o efeito de "quique", podemos usar a função de tempo`bounce`no modo`easeOut`.

Here's the final code for the animation:
Aqui está o código final para a animação:

```js
let to = field.clientHeight - ball.clientHeight;
Expand Down
4 changes: 2 additions & 2 deletions7-animation/3-js-animation/1-animate-ball/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,8 +2,8 @@ importance: 5

---

#Animate the bouncing ball
#Animar a bola quicando

Make a bouncing ball. Click to see how it should look:
Faça uma bola quicando. Clique para ver como deve ficar:

[iframe height=250 src="solution"]
20 changes: 10 additions & 10 deletions7-animation/3-js-animation/2-animate-ball-hops/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
In the task<info:task/animate-ball>we had only one property to animate. Now we need one more: `elem.style.left`.
Na atividade<info:task/animate-ball>nós tínhamos apenas uma propriedade para animar. Agora precisamos de mais uma: `elem.style.left`.

Thehorizontalcoordinate changes by another law: it does not "bounce",but gradually increases shifting the ball to the right.
A coordenadahorizontalé modificada por outra regra: ela não "quica",mas gradativamente aumenta a movimentação da bola para a direita.

We can write one more`animate`for it.
Podemos escrever mais um`animate`para isso.

As the time function we could use`linear`,but something like `makeEaseOut(quad)`looks much better.
Como função de tempo podemos usar`linear`,mas algo como `makeEaseOut(quad)`parece bem melhor.

The code:
O código:

```js
let height = field.clientHeight - ball.clientHeight;
let width = 100;

//animate top (bouncing)
//anime o topo (quicando)
animate({
duration: 2000,
timing: makeEaseOut(bounce),
draw: function(progress) {
ball.style.top = height * progress +'px'
draw: function(progress) {
ball.style.top = height * progress +"px"
}
});

//animate left (moving to the right)
//anime a esquerda (movendo para a direita)
animate({
duration: 2000,
timing: makeEaseOut(quad),
draw: function(progress) {
draw: function(progress) {
ball.style.left = width * progress + "px"
}
});
Expand Down
8 changes: 4 additions & 4 deletions7-animation/3-js-animation/2-animate-ball-hops/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,12 @@ importance: 5

---

#Animate the ball bouncing to the right
#Anime a bola quicando para a direita

Make the ball bounce to the right. Like this:
Faça a bola quicar para a direita. Assim:

[iframe height=250 src="solution"]

Write the animation code. The distance to the left is `100px`.
Escreva o código da animação. A distância para a esquerda é `100px`.

Take the solution of the previous task<info:task/animate-ball>as the source.
Use a solução da atividade anterior<info:task/animate-ball>como fonte.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp