Hero Animation
The Hero Animation component provides an elegant rotating text effect, perfect for hero sections where you want to cycle through different words or phrases.Overview
Implemented inhero-animation.js, this component creates a smooth letter-by-letter animation that cycles through multiple words, creating an engaging visual effect for headlines.
Implementation
The core animation logic fromhero-animation.js:1:
Letter Animation
Animate Out
Fromhero-animation.js:38:
Animate In
Fromhero-animation.js:44:
Text Splitting
The component splits words into individual letter spans (hero-animation.js:50):
Search Focus Handler
Bonus feature - automatic search input focus (hero-animation.js:77):
Auto-Initialization
Fromhero-animation.js:94:
HTML Structure
To use the hero animation, structure your HTML like this:CSS Requirements
You’ll need CSS to handle the letter animations:Configuration
Animation Timing
- Letter out delay: 80ms per letter (line 41)
- Letter in delay: 80ms per letter + 340ms offset (line 47)
- Word change interval: 4000ms (4 seconds) (line 74)
Special Characters
The component supports the special character¨ for invisible spacing:
Usage Example
Performance Notes
- Uses
setTimeoutfor precise timing control - Minimal DOM manipulation after initialization
- Only animates visible words
- No dependencies required
Browser Support
Works in all modern browsers that support:- ES6 arrow functions
getElementsByClassNamesetTimeout- CSS transitions

