Slide 1

Slide 1 text

CSS Animations Dražen Lučanin (@metakermit) (S)CSS Zagreb Meetup, 17.10.2019. What’s up, doc? #inktober edition

Slide 2

Slide 2 text

What is animation? • “Animation is a method in which pictures are manipulated to appear as moving images.” – Wikipedia

Slide 3

Slide 3 text

Anatomy of a rabbit walk • The 24-frame walk cycle • https://ezgif.com/maker/ezgif-4-bfe77455-gif

Slide 4

Slide 4 text

Anatomy of a rabbit walk More about walk cycles: https://www.the-flying-animator.com/walk-cycle.html contact pass position break the fall keyframes tweens

Slide 5

Slide 5 text

The simplest animation • Google Web Designer – https://webdesigner.withgoogle.com • Dreamweaver for creating ads • useful as a free animation tool • (with HTML/CSS export )

Slide 6

Slide 6 text

The simplest CSS animation https://codepen.io/metakermit/pen/QWWKNRY?editors=1100

Slide 7

Slide 7 text

CSS Properties • animation-name: none • animation-duration: 0s • animation-timing-function: ease • animation-delay: 0s • animation-iteration-count: 1 • animation-direction: normal • animation-fill-mode: none • animation-play-state: running

Slide 8

Slide 8 text

Keyframes • Can have multiple animated properties
 
 @keyframes falling-down {
 0% { top: 0px; left: 40px; }
 100% { top: 160px; left: 150px; }
 } • Multiple positions
 
 @keyframes falling-down {
 0% { top: 0px; }
 50% { top: 10px; }
 100% { top: 160px; }
 } • Instead of 0% / 100% you can use from / to
 
 @keyframes move_eye { from { margin-left: -20%; } to { margin-left: 100%; } }

Slide 9

Slide 9 text

Easing • Adapting the timing and spacing of frames to match real- world physics

Slide 10

Slide 10 text

Ease-in • No speed initially, gradually accelerate to a high speed • E.g. gravity pulling an object

Slide 11

Slide 11 text

Ease-out • High speed initially, gradually decelerate to no speed • E.g. a cyclist in motion breaks to amortise themselves to a stop

Slide 12

Slide 12 text

Ease-in-out • High speed initially, gradually decelerate to no speed • E.g. someone moves their arm • stationary • in motion • stationary again

Slide 13

Slide 13 text

SVGs? • They work exactly the same! • You can give classes to shapes and style them from CSS • (also possible to fully define animations inside SVGs) • Tutorial – https://css-tricks.com/animating-svg-css/

Slide 14

Slide 14 text

Parallax • A popular effect • But it’s obtained using JavaScript • Article – https://cssanimation.rocks/parallax/ • https://codepen.io/donovanh/pen/ZKJOBe # JaaaavaaaaScriiiiiipt

Slide 15

Slide 15 text

Can I use? • https://caniuse.com/#feat=css-animation

Slide 16

Slide 16 text

Animation resources • The Animator’s Survival Kit • Richard Williams
 (the animator of Who Framed Roger Rabbit) • An in-depth intro to animation • http://www.theanimatorssurvivalkit.com

Slide 17

Slide 17 text

CSS Animations resources • Syntax tutorial
 https://css-tricks.com/snippets/css/keyframe-animation-syntax/ • MDN
 https://developer.mozilla.org/en-US/docs/Web/CSS/animation • Projects, talks, articles and book by Rachel Nabors
 http://rachelnabors.com/ • Whole games using CSS animations! • http://rachelnabors.com/blackbrickroad/ • Some amazing projects on CodePen • https://codepen.io/miocene/pen/mjLPVp

Slide 18

Slide 18 text

• Amazing projects on CodePen, like the pure CSS "Moustached Nanny”
 https://codepen.io/miocene/pen/mjLPVp

Slide 19

Slide 19 text

No content