Refactor tilt animation engine for performance and maintainability#157
Open
Katotodan wants to merge 1 commit intomeshery-extensions:masterfrom
Open
Refactor tilt animation engine for performance and maintainability#157Katotodan wants to merge 1 commit intomeshery-extensions:masterfrom
Katotodan wants to merge 1 commit intomeshery-extensions:masterfrom
Conversation
Signed-off-by: DANIEL KATOTO <katotodan@gmail.com>
|
🚀 Preview deployment for PR #157 🌐 Preview URL: https://meshery-extensions.github.io/kanvas-site/pr-preview/pr-157/ This preview will be updated automatically when you push new commits to this PR. |
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.
Notes for Reviewers
Summary
This PR refactors the tilt animation engine to improve performance, reduce layout recalculations, and simplify the architecture.
The goal is to make the animation logic more scalable and maintainable while preserving the existing visual behavior.
Key Improvements
Centralized State
Introduced a
stateobject to manage:This removes the need for multiple scattered variables.
Visibility-Based Updates
Added an
IntersectionObserverto track visible elements.Only elements currently in the viewport are processed during animation updates.
Cached Layout Measurements
Bounding rectangles are cached and only recalculated when necessary:
This significantly reduces calls to
getBoundingClientRect().ResizeObserver Integration
ResizeObserveris used to detect element size changes and mark the layout as dirty only when needed.Scroll Throttling
Scroll updates are throttled using
requestAnimationFrameto avoid repeated layout invalidation.Read / Write Separation
The animation engine now clearly separates:
This helps prevent layout thrashing and improves animation smoothness.
GPU Rendering Hint
Tilt elements now receive:
This hints the browser to optimize rendering for smoother animations.
Result
The refactor improves:
while preserving the existing user-facing behavior.
Visual Changes
None intended.
The tilt and floating animations should behave the same as before.
Testing
Tested locally by:
[data-tilt]elementsAnimations behave as expected.
Part of Javascript: Improve animation performance #146
Signed commits