β‘ Optimize CSS animation to prevent layout thrashing #407
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.
π‘ What:
Refactored the text swap animation in
src/style.cssandindex.html. Instead of using a pseudo-element (::before) and animating thecontentproperty, I implemented a solution using multiple<span>elements stacked on top of each other using CSS Grid (display: grid; place-items: center). The animation now cycles through these elements by toggling theiropacityandvisibilityproperties.π― Why:
The previous implementation animated the
contentproperty. Changingcontentforces the browser to recalculate the layout (reflow) and repaint the page, which is an expensive operation known as "layout thrashing." By usingopacity(andvisibility), the animation logic is offloaded to the compositor thread (mostly) and avoids layout shifts, resulting in smoother performance and lower CPU usage.π Measured Improvement:
content(Layout trigger) toopacity(Composite trigger) is a known performance win.tests/animation-verification.spec.tsto ensure the new DOM structure is correctly rendered. All existing tests passed. Verified visually with screenshots.PR created automatically by Jules for task 3608634246665415621 started by @xRahul