Overview
Natours uses CSS keyframe animations to create smooth, engaging entrance effects. All animations are defined insass/base/_animations.scss and utilize GPU-accelerated transforms for optimal performance.
All animations use
transform and opacity properties exclusively to ensure hardware acceleration and smooth 60fps performance.Keyframe Animations
The project includes three primary keyframe animations for element entrance effects:moveInLeft
Animates elements entering from the left side of the screen with a subtle bounce effect.sass/base/_animations.scss
Bounce Point (80%)
Element overshoots slightly by 10px to the right, creating a natural bounce effect
sass/base/_typography.scss
moveInRight
Mirror animation tomoveInLeft, animating elements from the right side.
sass/base/_animations.scss
moveInLeft but in the opposite direction, creating visual balance when used with paired elements.
Usage Example:
sass/base/_typography.scss
moveInBottom
Animates elements entering from below, perfect for call-to-action buttons and secondary elements.sass/base/_animations.scss
sass/components/_button.scss
Animation Properties
Duration and Timing
Short Animations
Use 0.5s for buttons and small UI elements
Long Animations
Use 1s for large headings and hero elements
Animation Delay
Create staggered entrance effects by adding delays:Animation Fill Mode
animation-fill-mode: backwards ensures that elements start with the styles defined at 0% of the keyframe, even during the delay period. This prevents a flash of unstyled content before the animation begins.Real-World Examples
Hero Header Animation
The header combines multiple animations to create a coordinated entrance:Performance Considerations
GPU Acceleration
All Natours animations use transform properties which are GPU-accelerated:- ✅
transform: translateX() - ✅
transform: translateY() - ✅
opacity - ❌
left,right,top,bottom - ❌
width,height
Animation Timing Functions
All animations use theease timing function for natural, organic motion:
ease function provides:
- Slow start
- Fast middle
- Slow end
linear timing.
Customizing Animations
To create custom variations:Browser Compatibility
All animations are compatible with modern browsers. No vendor prefixes are required for:- Chrome 43+
- Firefox 16+
- Safari 9+
- Edge (all versions)
For older browser support, consider using Autoprefixer as part of your build process to automatically add vendor prefixes.