@RachelNabors
.com
Vue in Motion
where and how to use UI animation in your app
in space
WebAnimationWeekly.com
slack.AnimationAtWork.com
devtoolschallenger.com
lightningdesignsystem.com/design/
motion
Some bad news.
cdpn.io/collection/DgmzgG
Animation is a necessary part of
your complete and balanced user
experience.
bkaprt.com/aaw
master the basics and the rest will follow
CSS Transitions
A CSS transition describes 

how a element should show a
change to one of its CSS
properties.
color: blue color: pink
transition: color 800ms;
old value
transition: color 800ms;
new value
.ball {
}
.ball {
transition: <property> <duration> <delay> <easing>;
}
so this must
be the delay
duration alwayscomes first
Not today, Satan!
cdpn.io/XEJMdq
CSS Animations and Transitions:
the Definitive Course
rachelnabors.com/css-animations-course
gosh this looks familiar
Anatomy of Vue Animations
<transition name="warpdrive">
<p v-show="truthy">Thing to animate</p>
</transition>
<transition>
<p v-show="truthy">Thing to animate</p>
</transition>
<transition>
</transition>
cdpn.io/pen/GxmEmX
So you think you can <transition>?
• Dynamic components
• Component root nodes
• Condi9onal rendering using v-if
• Condi9onal display using v-show
Planning to change 

an element frequently?
Use v-show!
cdpn.io/pen/GxmEmX
class-based anima6ons
Hooks for Animating with CSS
<transition name="unCloaked"></transition>
.v-enter,
.v-enter-to,
.v-enter-active,
.v-leave,
.v-leave-to,
.v-active
Creates name-spaced CSS classes…
<transition name="unCloaked"></transition>
.unCloaked-enter,
.unCloaked-enter-to,
.unCloaked-enter-active,
.unCloaked-leave,
.unCloaked-leave-to,
.unCloaked-active
Creates name-spaced CSS classes…
<transition name="uncloak"><ship v-show="shipUncloaked" /></transition><transition name="uncloak"><ship v-show="shipUncloaked" /></transition><transition name="uncloak"><ship v-show="shipUncloaked" /></transition>
shipUncloaked : true
.uncloak-enter .uncloak-enter-to
shipUncloaked : true
<transition name="uncloak"><ship v-show="shipUncloaked" /></transition>
.uncloak-enter-to {

opacity: 1;

}
.uncloak-enter {

opacity: 0;

}
.uncloak-enter-active { 

transition: opacity 800ms;

}
<transition name="uncloak"><ship v-show="shipUncloaked" /></transition>
shipUncloaked : true
.uncloak-enter-to {

opacity: 1;

}
.uncloak-enter {

opacity: 0;

}
<transition name="uncloak"><ship v-show="shipUncloaked" /></transition><transition name="uncloak"><ship v-show="shipUncloaked" /></transition>
shipUncloaked : false
.uncloak-leave .uncloak-leave-to
.uncloak-leave-active
.uncloak-enter-active
shipUncloaked : true
.uncloak-enter-to.uncloak-enter
.ship {

opacity: 1;

}
shipUncloaked : falseshipUncloaked : true
.uncloak-leave-to
.cloak-leave-active
.uncloak-enter-active
.uncloak-leave.uncloak-enter-to.uncloak-enter
<transition name="uncloak"><ship v-show="shipUncloaked" /></transition>
cdpn.io/pen/GxmEmX
<transition name="warpdrive" appear>
<p>Thing to animate</p>
</transition>
<transition name="warpdrive">
<p v-if="truthy">Thing to animate</p>
</transition>
Appear
cdpn.io/pen/dmWJyg
for coordina6ng movements
Transition Groups
<transition>
<p>Other thing</p>
</transition>
<transition-group>
<div>Thing</div>
<p>Other thing</p>
<span>Thing</span>
</transition-group>
cdpn.io/XEJMdq
Multiple items within a
<transition group>
component? 

Set a unique key on each one!
mo’ elements, mo’ modes
Managing toggling elements
cdpn.io/pen/XEJMdq
<transition> modes
• in-out New element animates in first, then when
complete, the current element animates out.
• out-in Current element animates out first, then when
complete, the new element animates in.
cdpn.io/pen/XEJMdq
SNAPOH
cdpn.io/rdjjOm
‘cuz some6mes it’s already on the page
Animating static elements
cdpn.io/zWNNXL
cdpn.io/pen/zWNNXL
<div id="ui-panel"
v-on:click.once="activateConsole"
v-on:click="accessSystem = !accessSystem"
v-bind:class="{ ui_open : accessSystem }">
<div id="ui-panel"
v-on:click.once="activateConsole"
v-on:click="accessSystem = !accessSystem"
v-bind:class="{ ui_open : accessSystem }">
<div id="ui-panel"
v-on:click.once="activateConsole"
v-on:click="accessSystem = !accessSystem"
v-bind:class="{ ui_open : accessSystem }">
when you want your behavior in your JS
JavaScript Animation Hooks’
A “simple” animation with the
Web Animations API.
cdpn.io/XEgEQN
<transition name="uncloakJS">
<transition v-on:leave="uncloakJS">
<transition
  v-on:leave="uncloakJS"
  v-bind:css="false"
>
For fewer CSS conflicts 

& better performance, set 

v-bind:css="false" 

when animating with JavaScript!
.uncloak-enter,
.uncloak-leave-to {
opacity: 0;
}
.uncloak-enter-active,
.uncloak-leave-active {
transition: opacity 1000ms;
}
const uncloakAnimation = starship.animate(

[
{ opacity: 0},
{ opacity: 1}
], {
duration : 1000,
fill : "both"
});
<transition
  v-on:leave="uncloakJS"
  v-bind:css="false"
>
<transition
  v-on:leave="uncloakJS"
  v-bind:css="false"
>
const app = new Vue({
el: "#starfield",
data: {
shipUncloaked: true
},
methods: {
uncloakJS: function (el, done) {
uncloakingAnimation.onfinish = done;
uncloakingAnimation.play();
}
}
});
const app = new Vue({
el: "#starfield",
data: {
uncloaked: true
},
methods: {
uncloakJS: function (el, done) {
uncloakingAnimation.onfinish = done;
uncloakingAnimation.play();
}
}
});
methods: {
uncloakJS: function (el, done) {
uncloakingAnimation.onfinish = done;
uncloakingAnimation.play();
}
}
methods: {
uncloakJS: function (el, done) {
uncloakingAnimation.onfinish = done;
uncloakingAnimation.play();
}
}
No CSS? No done? No deal!
At least when it comes to using
enter and leave JavaScript
animation hooks!
cdpn.io/pen/GxvWZw
Check out these ace 

Web Animations API
resources to learn more:
rachelnabors.com/waapi
Giving users a choice
Accessible Animations
UI Animation can cause negative side effects like
• Seizures caused by flashing and blinking
• Nausea triggered by parallax mo9on
• Distrac-on and fa-gue brought on by looping anima9on
MediaQueriesLevel5Editor’sDra4
goo.gl/CcrVFs
cdpn.io/pen/zWNNXL
Progressive Enhancement FTW
DIY Animation Controls
Put the user in control.
This site uses anima,on and mo,on. Disable it?
cdpn.io/pen/KoXzLQ
Dem props!
• animationsOn: boolean
• motionQuery : matchMedia('(prefers-
reduced-motion)')
• accessibleAnimationQuerySupported: boolean
• prefersAnimation: boolean
cdpn.io/pen/KoXzLQ
cdpn.io/pen/KoXzLQ
What about JavaScript?
peaceOut : function(el){
if (this.animationsOn){
animation.play();
}
}
peaceOut : function(el, done){
if (this.animationsOn){
animation.play()
animation.onfinish = done;
} else {
done();
}
}
cdpn.io/qoPRbB
bkaprt.com/aaw
Thank you!
Chris Fritz
Sarah Drasner
And YOU!
@RachelNabors
.com
The pens: cdpn.io/collection/DgmzgG
The docs: vuejs.org/v2/guide/transitions.html
The dress: heruniverse.com

Vue in Motion