On Github wontem / animations-in-front-end
.elem { transition: opacity 3s 1s; } .elem { transition-property: opacity; transition-duration: 3s; transition-delay: 1s; } .elem { transition: transform .3s, opacity 3s 1s; } .elem { transition-property: transform, opacity; transition-duration: .3s, 3s; transition-delay: initial, 1s; }
Cubic bezier curve
Steps
Steps
Negative delay starts the animation at position corresponding absolute value of delay
.elem { animation: some-madness 3s infinite; } .elem { animation-name: some-madness; animation-duration: 3s; animation-iteration-count: infinite; } .elem { animation: move .3s, hide 2s 1s; } .elem { animation-name: move, hide; animation-duration: .3s, 2s; animation-delay: initial, 1s; }
@keyframes <name> rule defines scenario of animation
@keyframes some-madness { from { left: 0px; top: 200px; } 40%, 60% { left: 400px; background: brown; } to { left: 200px; top: 0px; } } .elem { animation: some-madness 3s infinite; }
For keyframed animations, the timing function applies between keyframes rather than over the entire animation
tbody:hover .elem { animation: move 2s ease 1; } @keyframes move { 0% { transform: translateX(-100%); } 25% { transform: translateX(-75%); } 50% { transform: translateX(-50%); } 75% { transform: translateX(-25%); } 100% { transform: translateX(0%); } }
Number of iterations. Infinite or float (for example 0.5 will play half of the animation cycle)
Specifies how a CSS animation should apply styles to its target before and after it is executing.
body:hover tr .elem { -webkit-animation: move 2s linear 1s; animation: move 2s linear 1s; }
tbody:hover tr .elem { -webkit-animation: move 2s 2 ease-in animation: move 2s 2 ease-in }
will-change property Accelerated Rendering in Chrome On translate3d and layer creation hacks High Performance Animations Translate performanse
Explanation of strange behavior and some tricks
Some Gotchas That Got MeVendor prefix and camelCase may require. For example webkitAnimationEnd
Runs callback function with before the next repaint.
var request; function step(timestamp) { document.body.innerHTML = timestamp; request = requestAnimationFrame(step); } request = requestAnimationFrame(step); setTimeout(function(){ cancelAnimationFrame(request); }, 1000);