Animations

Instead of one transition with transitions, can have up to an infinite number of iterations, grandular control

  • @keyframes

  • animation-name

  • animation-duration

  • animation-timing-function

  • animation-iteration-count

  • animation-direction

  • animation-play-state

  • animation-delay

  • animation-fill-mode

  • animation (shorthand)

@Keyframe

@keyframes clever_name_here ...
@keyframes writing {
    from { /*same as 0%*/
        left: 0;
    }

    to { /*same as 100%*/
        left: 100%;
    }
}
  • % basically the total animation time

  • !important not important in animations

  • It repaints the page when you change left/top, should use transform

Using Keyframe

  • By default happens once

  • Can have multiple animations happening on same element at same time, last declared animation overrides other props if same props

Timing Function

linear |ease-in-out|ease-in|ease-out|step-start|step-end|ease|steps(X, start|end)|cubic-bezier(x1, y1, x2, y2)

Steps

Discrete steps

start/end is which frame you drop i.e 2-4-6-8-10 or 0-2-4-6-8-10

Sprites(is a strip animate with:), add second animation to make it move across screen

Iteration-count

Can even do partial count so cuts off

Animation-delay

Can even do negative and skips in animation time

Animation-Direction

normal | alternate|reverse|alternate-reverse

Animation(shorthand)

name duration delay timing-function iteration-count

Animation Fill Mode

None | forwards | backwards | both

What do after last animation?

  • None: go back

  • forwards: keep at 100%

  • backwards: keep at 0% during animation delay/start

Play-state

Running | paused

Events

  • animationstart

  • animationend

  • animationiteration

Can add and remove class of animation at animation end to restart event(put slight delay on regiving class)

Advanced

On Unmount Animation

Last updated