In this episode we focus on CSS transitions and animations, what they are, why they both exist, and when you should use one or the other.
Segment 1 - Transitions vs Animations
- AdobePress Article - reference link
Transitions- Only have two states (triggered and not triggered)
Always run forward when triggered, and backwards when the trigger is removedCommon triggers are: hover, link, active, visited, focus, checked, disabledCommon use case: hover over a button and have the box shadow get darker as long as the cursor is hovering over itAnimations- More control than transitions
Can start, stop, pause, run forwards, run backwardsComplex animations are possible by manipulating various properties within keyframesMay be more difficult to manipulate with JavascriptUse animations if you need the complexityUse transitions if you have a simple affect that only needs two states (triggered, not triggered)Segment 2 - How Transitions and Animations Improve UX
- Build your site with animations in mind so they don't look tacked on after the fact
Don't be too flashy - your animations need to have purpose, shouldn't get in the way of the user experienceDon't overwhelm the user with animations - may cause performance issues, can distract the userKeep animations consistent with the associated action - swipes with sliding animation, taps w/ pebble drop in water animation- Too many transitions or complex animations can cause serious performance issues
The browser runs animations better over time (device starts to dedicate resources to the tab, cache builds up) so tests need to be done on a fresh incognito (or equivalent) window to ensure performance is good for first time usersTest on older devices that may have slow hardware, or may have older browsers due to lack of support for newer updatesPerformance "hacks" - translate3d, translatez- More modern method "will-change"
Check out José Rosário’s page on Medium article: https://medium.com/outsystems-experts/how-to-achieve-60-fps-animations-with-css3-db7b98610108 for an in-depth breakdownSegment 4 - Animation Frameworks
Full 3D render capableIs complex to start withhas been around now for 8+ years so a little bit bloated yet still supportedAnime.js- Fastest/best performance large scale animation library
Extremely lightweightCould replace Three.js due to simplicity and modern architectureScrollReveal.js- Specific library for animation while scrolling
Using specific libraries for certain tasks maskes code more lightweightUsually easier to implement then a larger more customizable libraryWeb News - Inconsistencies and Separation
- Mobile versions (app or mobile site) vs Desktop versions (apps or site)
Separation of apps (multiple apps - same service/function)Inconsistent development features in an ecosystemFacebook | Twitter | Instagram
Medium | YouTube | GitHub