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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JavaScript Animations #136
base: master
Are you sure you want to change the base?
JavaScript Animations #136
Conversation
|
|
||
| An animation can be implemented as a sequence of frames -- usually small changes to HTML/CSS properties. | ||
| A animação pode ser implmentada como uma sequência de frames (quadros) -- geralmente pequenas modificações nas propriedades de HTML/CSS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor typo: implmentada -> implementada
|
|
||
| ```js | ||
| let start = Date.now(); // remember start time | ||
| let start = Date.now() // preservar o tempo inicial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont change the code, keep the ';'
| let timer = setInterval(function() { | ||
| // how much time passed from the start? | ||
| let timePassed = Date.now() - start; | ||
| let timer = setInterval(function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please dont change the code, keep the same spaces as in the original
| let timePassed = Date.now() - start; | ||
| let timer = setInterval(function () { | ||
| // quanto tempo passou desde o início? | ||
| let timePassed = Date.now() - start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, keep the ';'
| if (timePassed >= 2000) { | ||
| clearInterval(timer); // finish the animation after 2 seconds | ||
| return; | ||
| if (tempoPetimePassedrcorrido >= 2000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also dont translate the variables names
|
Please make the requested changes. After it, add a comment "/done". |
|
Hi, Karla! Doing fine? Please don't translate or change the source code in the examples. Could you take a look into that? Like, you should keep the ';', spaces and variable names. Cheers! |
Hey, yeah. I'm addressing feedback now. My linter changed the code, fixing that :) |
|
/done |
|
Hi @karlasamantha would you please also resolve the conflicts, or kindly inform if unavailable to? Thank you. |
|
Hi @karlasamantha , please I wonder if you could resolve the conflicts, or kindly inform if unavailable to? Thank you. |
Hi @odsantos , sorry for the delay! I'll try to fix the conflicts today! |
|
/done |
|
/done |
|
Hi @karlasamantha , thank you. |
Hi @karlasamantha ,
The article review is still missing, hopefully to another time.
Please, feel free to leave a note on something you may not agree.
Thank you.
|
|
||
| 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, a posição da borda é `field.clientHeight - ball.clientHeight`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| A coordenada inferior do campo é `field.clientHeight`. Mas a propriedade `top` fornece coordenadas para o topo da bola, a posição da borda é `field.clientHeight - ball.clientHeight`. | |
| 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. | ||
| Então animamos a propriedade `top` a partir de `0` até `field.clientHeight - ball.clientHeight`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Então animamos a propriedade `top` a partir de `0` até `field.clientHeight - ball.clientHeight`. | |
| 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: | ||
| Para obter o efeito de "quique", podemos usar a função de tempo `bounce` no modo `easeOut` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Para obter o efeito de "quique", podemos usar a função de tempo `bounce` no modo `easeOut` | |
| Aqui está o código final para a animação: |
|
|
||
| Here's the final code for the animation: | ||
| Para obter o efeito de "quique", podemos usar a função de tempo `bounce` no modo `easeOut` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Here's the final code for the animation: | ||
| Para obter o efeito de "quique", podemos usar a função de tempo `bounce` no modo `easeOut` | ||
|
|
||
| Aqui está o código final para a animação: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Aqui está o código final para a animação: | |
| ```js |
| draw: function(progress) { | ||
| ball.style.top = height * progress + 'px' | ||
| draw: function (progress) { | ||
| ball.style.top = height * progress + "px" | ||
| } | ||
| }); | ||
| // animate left (moving to the right) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // animate left (moving to the right) | |
| // anime a esquerda (movendo para a direita) |
|
|
||
| [iframe height=250 src="solution"] | ||
|
|
||
| Write the animation code. The distance to the left is `100px`. | ||
| Escreva o código de animação. A distância para a esquerda é `100px`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Escreva o código de animação. A distância para a esquerda é `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 a fonte. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Use a solução da atividade anterior <info:task/animate-ball> como a fonte. | |
| Use a solução da atividade anterior <info:task/animate-ball> como fonte. |
| And stood awhile in thought. | ||
| <textarea id="textExample" rows="5" cols="60"> | ||
| Ele pegou sua espada vorpal na mão: | ||
| Faz tempo que o manxome inimigo que ele procurava - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Faz tempo que o manxome inimigo que ele procurava - | |
| Faz tempo que o inimigo manxome ele procurava - |
| Ele pegou sua espada vorpal na mão: | ||
| Faz tempo que o manxome inimigo que ele procurava - | ||
| Então ele descansou perto da árvore Tumtum, | ||
| E ficou um pouco em pensamento. | ||
| </textarea> | ||
|
|
||
| <button onclick="animateText(textExample)">Run the animated typing!</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <button onclick="animateText(textExample)">Run the animated typing!</button> | |
| <button onclick="animateText(textExample)">Corra o texto animado!</button> |
|
Please make the requested changes. After it, add a comment "/done". |
Hi @karlasamantha ,
Here is the whole review.
Please, feel free to leave a note where you might not agree.
Thank you,
Osvaldo.
|
|
||
| The pseudo-code can look like this: | ||
| O pseudo-código pode ficar assim: | ||
|
|
||
| ```js | ||
| let timer = setInterval(function() { | ||
| if (animation complete) clearInterval(timer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (animation complete) clearInterval(timer); | |
| if (animação completa) clearInterval(timer); |
|
|
||
| The pseudo-code can look like this: | ||
| O pseudo-código pode ficar assim: | ||
|
|
||
| ```js | ||
| let timer = setInterval(function() { | ||
| if (animation complete) clearInterval(timer); | ||
| else increase style.left by 2px |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| else increase style.left by 2px | |
| else incremente style.left em 2px |
| // as timePassed goes from 0 to 2000 | ||
| // left gets values from 0px to 400px | ||
| // timePassed vai de 0 a 2000 | ||
| // recebe valores de 0 a 400px |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // recebe valores de 0 a 400px | |
| // 'left' recebe valores de 0 a 400px |
| draw(timePassed); | ||
| }, 20); | ||
| // as timePassed goes from 0 to 2000 | ||
| // left gets values from 0px to 400px | ||
| // timePassed vai de 0 a 2000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // timePassed vai de 0 a 2000 | |
| // enquanto timePassed vai de 0 a 2000 |
| - <span style="color:#EE6B47">Red</span> is the regular variant of `circ` (`easeIn`). | ||
| - <span style="color:#8DB173">Green</span> -- `easeOut`. | ||
| - <span style="color:#EE6B47">Red</span> é a variante regular de `circ` (`easeIn`). | ||
| - <span style="color:#8DB173">Greed</span> -- `easeOut`. | ||
| - <span style="color:#62C0DC">Blue</span> -- `easeInOut`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - <span style="color:#62C0DC">Blue</span> -- `easeInOut`. | |
| - <span style="color:#62C0DC">Azul</span> -- `easeInOut`. |
|
|
||
| Here's the animated "bouncing" text typing: | ||
| Aqui está o texto animato "quicando": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Aqui está o texto animato "quicando": | |
| Aqui está o texto animado "quicando": |
|
|
||
| For animations that CSS can't handle well, or those that need tight control, JavaScript can help. JavaScript animations should be implemented via `requestAnimationFrame`. That built-in method allows to setup a callback function to run when the browser will be preparing a repaint. Usually that's very soon, but the exact time depends on the browser. | ||
| Para animação que CSS não lida bem, ou aquelas que precisam de controle rígido, JavaScript pode ajudar. Animações JavaScript devem ser implementadas via `requestAnimationFrame`. Esse método embutido permite configurar uma callback para que seja executada quando o navegador estiver preparando uma repintura. Geralmente é bem breve, mas o tempo exato depende do navegador. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Para animação que CSS não lida bem, ou aquelas que precisam de controle rígido, JavaScript pode ajudar. Animações JavaScript devem ser implementadas via `requestAnimationFrame`. Esse método embutido permite configurar uma callback para que seja executada quando o navegador estiver preparando uma repintura. Geralmente é bem breve, mas o tempo exato depende do navegador. | |
| Para animação que CSS não lida bem, ou aquelas que precisam de controle rígido, JavaScript pode ajudar. Animações com JavaScript devem ser implementadas via `requestAnimationFrame`. Esse método embutido permite configurar uma callback para que seja executada quando o navegador estiver preparando uma repintura. Geralmente é bem breve, mas o tempo exato depende do navegador. |
|
|
||
| JavaScript animations can use any timing function. We covered a lot of examples and transformations to make them even more versatile. Unlike CSS, we are not limited to Bezier curves here. | ||
| Animações JavaScript podem usar qualquer função de tempo. Cobrimos muitos exemplos e transformações para fazê-las ainda mais versáteis. Ao contrário de CSS, não estamos limitados às curvas de Bezier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Animações JavaScript podem usar qualquer função de tempo. Cobrimos muitos exemplos e transformações para fazê-las ainda mais versáteis. Ao contrário de CSS, não estamos limitados às curvas de Bezier. | |
| Animações com JavaScript podem usar qualquer função de tempo. Cobrimos muitos exemplos e transformações para fazê-las ainda mais versáteis. Ao contrário de CSS, não estamos limitados às curvas de Bezier. |
|
Please make the requested changes. After it, add a comment "/done". |
Co-authored-by: Osvaldo Dias dos Santos <vadodsantos@yahoo.com>
Co-authored-by: Osvaldo Dias dos Santos <vadodsantos@yahoo.com>

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

No description provided.