Creating Smooth Scroll-Synchronized Animation for OPTIKKA
In today’s digital landscape, delivering engaging content is essential for any website. This blog post explores how we transformed the user experience for OPTIKKA, a platform known for revolutionizing design workflows, by employing innovative animation techniques.
The Initial Approach: HTML5 Video
Why It Seemed Promising
When we first tackled the animation for OPTIKKA, we considered using HTML5 video in combination with GSAP’s ScrollTrigger for seamless scroll-triggered animations. This method had its merits, including:
- Simplicity: Browsers natively support video playback.
- Compactness: It requires a single video file rather than multiple images.
- Compression: Video codecs can significantly reduce file sizes.
However, this method had notable drawbacks:
- Performance Issues: Experiences of stuttering and lag, especially on mobile.
- Autoplay Restrictions: Many browsers impose limitations on autoplay features.
- Visual Quality Loss: Compression often degrades animation quality.
Transition to Frame Sequences
What Is a Frame Sequence?
Frame sequences utilize a series of individual images displayed in quick succession, mimicking motion akin to a film running at 24 frames per second. This technique allows for precise control over both animation timing and image quality.
Extracting Frames from Video
To enhance the animation quality, we leveraged FFmpeg to convert videos into individual frames, which we then optimized in web-friendly formats:
- Start with the source video.
- Split it into PNG frames.
- Convert the PNGs to WebP format for size efficiency.
Device-Specific Sequences
To ensure optimal performance on various devices, we developed two different sets of image sequences:
- Desktop Applications: Higher frame counts for a smoother experience.
- Mobile Applications: Lower frame counts for quicker loading times.
Intelligent Frame Loading System
The Challenge
Loading more than a thousand images poses a challenge, particularly in maintaining a responsive UI and efficient bandwidth utilization. Users expect instantaneous animations, but extensive image sequences can slow the experience.
Stepwise Loading Solution
We implemented a stepwise loading system that prioritizes user experience as follows:
- Immediate Start: Load the first 10 frames instantly.
- Overview Display: Users are greeted with animation immediately.
- Background Loading: The remaining frames load seamlessly in the background.
Rendering with Canvas
Why Canvas?
By rendering frames within an HTML <canvas> element, we enjoy multiple advantages:
- Instant Rendering: Frames load into memory for immediate use.
- No DOM Reflow: This method avoids unnecessary repainting of the page.
- Smooth Animation: The canvas works efficiently with requestAnimationFrame.
Performance Optimizations
Dynamic Preloading Based on Scroll Direction
To enhance user experience further, we adopted a dynamic preloading strategy:
- Scroll Down: Preload five frames ahead.
- Scroll Up: Preload five frames behind.
Results of the Transition
Benefits
The switch from video to frame sequences yielded several advantages:
- Consistent performance across devices.
- Predictable memory usage with no playback stuttering.
- Flexibility in autoplay and improved user experiences.
Technical Trade-offs
While the enhancements improve user experience, they do come with trade-offs:
- Increased bandwidth from multiple image requests.
- Larger overall data sizes.
- Added complexity in implementation.
Conclusion
The transition from HTML5 video to frame sequences for OPTIKKA underscored the importance of selecting the right technology for the task. Despite the added complexity, this new approach resulted in:
- Reliable performance across devices.
- Smooth and consistent animation.
- Enhanced control for diverse scenarios.
Sometimes, embracing a more complex solution is necessary for a superior user experience.
Related Keywords: scroll-synchronized animation, frame sequences, GSAP ScrollTrigger, HTML5 video, canvas rendering, FFmpeg, website performance optimization.

