🧠 Description
This project showcases an elegant parallax scroll effect using GSAP's ScrollSmoother and ScrollTrigger plugins.
The animation features a hero section with a parallax image that scales and transforms as users scroll, combined with smooth scrolling for enhanced user experience.
Additional effects include overlay opacity transitions, title animations, and text fade-out sequences that trigger at specific scroll positions.
The design creates an immersive storytelling experience perfect for landing pages, portfolio showcases, and content-heavy websites.
💻 HTML Code
HTML Structure Explanation
The HTML uses a wrapper and content structure specifically designed for ScrollSmoother:
Key Elements:
#smooth-wrapper- Outer container required by ScrollSmoother plugin#smooth-content- Inner wrapper that scrolls smoothly.hero-container- Main hero section container.hero- Hero content area with full viewport height.hero__content- Contains background image and title.hero__bg- Background image layer that parallaxes.hero__title- Text that animates during scroll.hero__cover- Overlay layer with image that scales during scroll.section-stick- Sticky text section that fades on scroll.hobbiton- Final image section
The nested structure allows ScrollSmoother to apply smooth scrolling effects to the entire page while individual sections trigger GSAP animations.
External GSAP plugins (ScrollTrigger and ScrollSmoother) are loaded via CDN.
🎨 CSS Code
CSS Breakdown
Color System
CSS custom properties (--black, --white) provide consistent theming throughout.
Hero Section Layout
.hero-container and .hero establish full-viewport height sections.
overflow: hidden ensures content stays within bounds during transforms.
Background Image Parallax
.hero__bg uses will-change property to hint GPU acceleration for smooth animations.
filter: blur(3px) brightness(1.5) creates initial atmospheric effect.
The background will scale and adjust filters during scroll.
Hero Title Styling
clamp(3rem, 15vw, 12rem) ensures responsive typography across screen sizes.
Initial scale(0.5) and opacity: 0 set the starting animation state.
filter: blur(10px) creates initial blurred appearance that clarifies on scroll.
Cover Layer
--overlay-opacity: 1 is a CSS variable that GSAP will animate to 0.
perspective: 500px enables 3D transform effects on the image.
Radial gradient overlay creates depth and vignette effect.
Sticky Text Section
Flexbox centers large responsive text perfectly in viewport.
Will be pinned and animated with fade-out effect during scroll.
Final Image Section
object-fit: cover ensures image fills full height without distortion.
Radial gradient overlay darkens edges for visual cohesion.
Performance Optimization
will-change declarations prepare browser for animated properties.
Smooth scrolling is handled entirely by ScrollSmoother plugin.
⚙️ JavaScript Code
JavaScript Breakdown
Plugin Registration
gsap.registerPlugin(ScrollTrigger, ScrollSmoother) - Enables scroll-trigger functionality and smooth scrolling.
Smooth Scrolling Setup
ScrollSmoother.create() initializes smooth scrolling with three key options:
smooth: 1- Duration in seconds for scroll smoothing effecteffects: true- Enables special scroll effects and parallaxnormalizeScroll: true- Normalizes scroll behavior across different browsers
This creates the silky smooth scrolling experience throughout the page.
Hero Timeline Animation
Creates a GSAP timeline synchronized with scroll progress:
ScrollTrigger Configuration:
trigger: ".hero-container"- Animation starts when hero container enters viewportstart: "top top"- Begins when top of hero reaches top of viewportend: "+=150%"- Ends after scrolling 150% of the viewport heightpin: true- Pins the hero section in place during animationscrub: 1- Syncs animation with scroll (1 second smoothing delay)
Staggered Animations (using "<" for simultaneous playback):
-
.hero__cover-img:scale: 2- Zooms image to 2x sizez: 350- Moves element forward in 3D spaceease: "power1.inOut"- Smooth acceleration/deceleration
-
.hero__cover:"--overlay-opacity": 0- Animates CSS variable from 1 to 0, fading overlay
-
.hero__bg:scale: 1.1- Subtle zoom on backgroundfilter: "blur(0px) brightness(1)"- Removes blur and brightens background
-
.hero__title:scale: 1- Grows from 0.5 to full sizeopacity: 1- Fades in from transparentfilter: "blur(0px)"- Removes blur for sharp appearance
Text Fade Timeline
Second animation controls the sticky text section:
ScrollTrigger Configuration:
trigger: ".section-stick"- Animation tied to text sectionstart: "center center"- Animation begins when section center reaches viewport centerend: "+=1000"- Continues for 1000px of additional scrollingpin: true- Pins section in place while fadingscrub: true- Directly syncs animation to scroll speed
Animation:
.opacity-reveal:opacity: 0- Fades text from visible to invisiblescale: 1.2- Simultaneously scales up for expanding effect
Result
The combined effect creates an immersive parallax experience where:
- Smooth scrolling makes all interactions feel polished
- Hero section pins and animates complex multi-layer transforms
- Text fades and scales as users reach the sticky section
- Multiple properties animate in perfect synchronization with scroll position
This architecture is ideal for premium portfolio sites, storytelling websites, and experiences that prioritize polish and user engagement.
