Fixed Learn button continuous loop animation#708
Open
paras2707 wants to merge 7 commits intoaccordproject:mainfrom
Open
Fixed Learn button continuous loop animation#708paras2707 wants to merge 7 commits intoaccordproject:mainfrom
paras2707 wants to merge 7 commits intoaccordproject:mainfrom
Conversation
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: Paras Thapar <73242340+paras2707@users.noreply.github.com>
mttrbrts
requested changes
Feb 15, 2026
Member
mttrbrts
left a comment
There was a problem hiding this comment.
I agree that the loop animation should be removed.
Although, can you instead have the hover behaviour match the Discord and Github buttons, pleasE?
Author
Ok, i'll look into it. |
Signed-off-by: Paras Thapar <parasthapar2001@gmail.com>
Author
|
I’ve addressed the requested changes. Please review again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Infinite Animation Loop on Learn Button in Navbar
Overview
Fixed a bug in the Learn button animation that was continuously looping indefinitely. The button now animates with a controlled, finite pulse effect that respects user accessibility preferences.
Problem Statement
The Learn button on the Navbar was displaying a continuously re-triggering animation. While
loop: falsedid stop the animation from looping infinitely, the animation hook was being re-created on every render/UI state change, causing the animation to restart repeatedly and flash persistently. This created a distracting, flickering effect that disrupted the user experience.Root Cause
The original implementation used
useSpringwith a static configuration:Issue: The
useSpringhook was being recreated on every component render (whenever props or state changed). Since the animation was defined directly in the component body without memoization or effect control, each render would restart the animation. This caused the button to continuously pulse/flash every time the Navbar re-rendered—a much more disruptive problem than an infinite loop.Solution
Replaced the stateless
useSpringconfiguration with a combination ofuseSpring+useEffect+ controlled animation state, which:useEffectso it only runs once on component mount, not on every renderapi.start) within an effect dependency array, ensuring the animation starts only when intendedChanges Made
Before (Lines 193–200)
After (Lines 200–230)
Key Improvements
prefers-reduced-motion✅animationStoppedflag ✅Behavior Explanation
Animation Flow
The animation now runs once on component mount and completes:
Key Difference: Previously, every UI state change (hover, routing, etc.) would re-render the component and restart the animation. Now, the animation is isolated in a
useEffectand only runs once on initial mount, preventing the re-triggering effect.Accessibility
Cleanup
Technical Deep Dive: Why Async/Await?
The animation uses an async function with await statements—this is crucial for controlling the animation sequence:
Why This Pattern?
1. Sequential vs. Parallel Animation
await: Both animation phases would try to run simultaneously, overriding each otherawait: Eachnext()call waits for the previous animation to complete (500ms) before starting the next one2. Control Over Timing
await next(...)is a promise that resolves when that specific animation completes3. Safety with Component Unmount
await, we checkif (animationStopped)and exit early if the component unmounted4. Finite Loop Control
for loopwithpulseIterationsensures exactly N pulsesThe Problem Without Async/Await
If the code was:
animationStoppedbetween phasesTesting Recommendations
Technical Notes
react-spring@^9.7.4(already in dependencies)async generatorpattern fromreact-springfor sequential animations