Choose
Your
Animation
Adventure
Val Head • @vlh
Author of Designing Interface Animation
Design Advocate, Adobe
Slide 2
Slide 3
You have encountered an interface that requires animation.
What would you like to use?
(1)
CSS?
(2)
JavaScript?
(3)
SVG?
(4)
…?
Slide 4
Slide 5
CSS
Key
Frames
Transitions
Slide 6
What CSS is great at:
•
Well-defined state transitions
•
Loading animations, looping animations
•
Animations on :hover, :focus and similar
CSS
Slide 7
Slide 8
Slide 9
Slide 10
Slide 11
Slide 12
Pros:
•
No external library needed
•
Great potential for performance without much
e
!
ort
•
Keyframes are reusable
•
Can adjust properties in media queries for
responsive animation when needed
CSS
Slide 13
Cons:
•
Access to limited events
•
Defined entirely ahead of time
•
Can’t separate transform properties*
CSS
Slide 14
CSS
+
JS
!
Slide 15
Slide 16
Slide 17
CSS
In Summary
Where it shines:
•
Animated interactions with defined states
•
Simple interactive animations
Biggest Pro:
•
Nearly e
!
ortless performance
•
No additional requests
Slide 18
CSS is pretty great, but it might be
time to move to JavaScript if:
•
You’ll be chaining more than 3-ish animations in a
sequence
•
The animation needs to change dynamically at runtime
•
Need to animate transform properties separately
•
Physics or other complex easing structures are required
Slide 19
Vanilla
Canvas
Web GL
react
Libs
Web Animation
API
JS
Slide 20
What javascript is great at:
JS
•
Complex animated interactions
•
Narrative or immersive animation
•
Dynamic state transitions
~9 - 29kb
~14.4kb
~4.7kb
back to IE8*
back to IE8
back to IE10
Docs + forums
Docs + SO
Docs
drawSVG, morphSVG, Draggable
drop-in replacement for jQuery
very lightweight
Some features and licensing
requires $
MIT license
MIT license
*These are not the only JS animation libraries out there.
Slide 38
JavaScript
In Summary
Where it shines:
•
Complex UI animation
•
Animation with dynamic states
•
Immersive animation
Biggest Pro:
•
Lots of options for how to get it done
•
Can animate DOM, SVG, canvas
Slide 39
SVG
Slide 40
Slide 41
Slide 42
What SVG is great at:
SVG
•
Animated illustrations
•
Animated icons
•
Infographics and dataviz
•
Fluidly scaling, responsive animation
Slide 43
Slide 44
Slide 45
Slide 46
Slide 47
Slide 48
SMIL
•
Tag-based animation within
SVG
•
No IE or Edge support
•
Future in Chrome uncertain
“
$
CSS
•
Transitions and keyframe
animations can be applied to
SVG elements
•
Limited number of properties
are exposed to CSS
•
Transforms on child elements
not supported in IE*
JS
•
Can access/animate native
SVG properties
•
Can do motion along path,
shape morphing and more just
like SMIL
Slide 49
Slide 50
airbnb.design/lottie/
Slide 51
lottiefiles.com
Slide 52
github.com/airbnb/lottie-web
Slide 53
SVG
In Summary
Where it shines:
•
Animated illustrations & infographics
•
Shape morphing
•
Motion along a path
Biggest Pro:
•
Responsive by nature
•
Potential for tiny file sizes
Slide 54
PERFORMANCE
Slide 55
size
transform: scale()
position
transform: translate()
rotation
transform: rotate()
opacity
Slide 56
composite
paint
layout
style
Slide 57
Slide 58
Slide 59
CSS
JavaScript
•
CSS is declarative
(whole animation is known ahead of
time)
•
CSS animations with transform &
opacity won’t be impacted by the
main thread
•
JS is imperative
(browser only really aware of the
current frame)
•
Hardware acceleration isn’t
automatic
Slide 60
SVG & Hardware Acceleration?
•
Not all browsers support it
•
Good performance in general without it though
Slide 61
Slide 62
You have encountered an interface that requires animation.
What would you like to use?
(1)
…?
Slide 63
Designing Interface Animation
designinginterfaceanimation.com
20% O
!
:
“valhead”