Text Animations
initTextRevealAnimation()
Initializes scroll-triggered text reveal animations with swipe-up effect using GSAP.
Parameters
CSS selector for the container element
Optional configuration object for customizing the animation behavior
TextRevealOptions
CSS selector for elements to animate within the container
Delay in seconds between each element’s animation start
ScrollTrigger start position (when element reaches this viewport position)
Animation duration in seconds
Usage Examples
Animation Details
- Effect: Elements animate from below (y offset) to their final position with opacity fade-in
- Easing:
power3.outfor smooth deceleration - Trigger: Animations reverse when scrolling back up
- Toggle Actions:
"play none none reverse"
createTextSwipeAnimation()
Creates a reusable swipe-up animation for text elements triggered when a section occupies more than 50% of the viewport.
Parameters
CSS selector of the elements to animate
DOM element of the section that acts as the scroll trigger
Returns
Returns the created ScrollTrigger instance, or
undefined if no elements match the selectorUsage Examples
Custom Delays
Elements can specify custom animation delays using thedata-delay attribute:
Animation Details
- Trigger Point: When section reaches 50% viewport height (
start: "top 50%") - Default Stagger: 0.15s between elements (index * 0.15)
- Duration: 1.2 seconds
- Easing:
power3.out - Timeline: Uses GSAP timeline for orchestrated animations with proper reverse behavior
Text Utilities
normalizeSlug()
Transforms text into URL-friendly slug format by removing accents, converting to lowercase, and replacing spaces with hyphens.
Parameters
Input text to convert to a slug
Returns
URL-friendly slug with no accents, lowercase, hyphen-separated
Transformation Rules
- NFD Normalization: Decomposes accented characters
- Remove Diacritics: Strips accent marks (\u0300-\u036f)
- Lowercase: Converts all characters to lowercase
- Replace Spaces: Converts spaces to hyphens
- Remove Special Chars: Removes non-word characters except hyphens
- Deduplicate Hyphens: Replaces multiple consecutive hyphens with single hyphen
- Trim Hyphens: Removes leading and trailing hyphens
Usage Examples
Common Use Cases
Dependencies
The animation utilities require GSAP and ScrollTrigger:Source Locations
src/utils/textRevealAnimation.ts:1-56src/utils/textSwipeAnimation.ts:1-51src/utils/slug.ts:1-13