Camp Digital
Thursday April 23rd
Ben Holden
@BenHoldenPrime
Liam Richardson
@meevil
By the end of this presentation, you'll have learned how to...
Let's begin our whistle stop tour!
.button {
transition: background 1s ease;
}
The transition property can be triggered by any kind of "state" change
The transition property allows you to smoothly affect an element when changing from one state to another
Hover me!
Hover me!
.button{
transition: background 1s all;
background: white;
}
.button:hover{
background: pink;
}
Hover
.button {
transition: background 1s ease;
background: white;
}
.button {
transition: background 1s ease;
background: white;
}
.button:hover {
background: pink;
}
transition-property: width;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 2s;
transition: width 1s linear 2s;
transition: width 2s, height 2s, transform 2s;
transition: all 2s linear;
@mixin transition($transition-property, $transition-time, $method) {
transition: $transition-property $transition-time $method;
}
Supports 81 properties
Classed as "Animatable"
http://oli.jp/2010/css-animatable-properties/
On the majority of projects?
@keyframes mymove {
from {top: 0px;}
to {top: 200px;}
}
Keyframes allow you to create amazing animations that work
seamlessly across
modern browsers
Keyframes are essentially a list of what the animation should do over a defined period of time
.car {
animation-name: drive;
animation-duration: 2s;
}
@keyframes drive {
from {margin-left: 0px;}
to {margin-left: 400px;}
}
@keyframes drive {
from {margin-left: 0px;}
to {margin-left: 400px;}
}
@keyframes drive {
0% {margin-left: 0px;}
50%{margin-left: 400px;}
100% {margin-left: -200px;}
}
linear
ease-in
ease-out
What can you change using @keyframes?
The same 81 properties that you can influence with transition can be changed with @keyframes as well
On projects that require additional visual "flair" or engagement that traditional methods can't provide.
Adding fluidity to an otherwise static design
http://codepen.io/Xpressive_Team/full/LeHGF/
SVG + CSS animation = Awesomeness
Code you can apply classes too!
<rect class="background" fill="#D03E27" width="400" height="400" />
<path class="letter" fill="#F4F4F4" d="M60.858,129...." />
<path class="letter" fill="#F4F4F4" d="..." />
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear alternate infinite;
}
@keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
A larger playset - SVG
only properties
clip-rule, flood-color, flood-opacity, stop-opacity, kerning, tech-anchor, color-profile, color-rendering, fill, fill-opacity, fill-rule, marker, marker-end, marker-mid, marker-start, stroke, stroke-width, stop-color, lighting-color, enable-background, dominant-baseline, color-interpolation-filters, color-interpolation, glyph-orientation-horizontal, glyph-orientation-vertical, shape-rendering, baseline-shift, alignment-baseline, stroke-miterlimit, stroke-linejoin, stroke-linecap, stroke-dashoffset, stroke-dasharray, stroke-opacity
"When used as more than just a subtle design detail, animation can provide cues, guide the eye, and soften the sometimes-hard edges of web interactions. It can improve the user experience."
http://alistapart.com/article/ui-animation-and-ux-a-not-so-secret-friendship
Val Head, A List Apart
Get experimenting
with transitions!
/* Chrome, Safari, Opera */
@-webkit-keyframes myfirst {
0% {background: red;}
25% {background: yellow;}
50% {background: blue;}
100% {background: green;}
}
/* Standard syntax */
@keyframes myfirst {
0% {background: red;}
25% {background: yellow;}
50% {background: blue;}
100% {background: green;}
}
@meevil
@BenHoldenPrime