-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Layout animation builder #3528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Layout animation builder #3528
Conversation
Introduces layoutAnimation.add() and layoutAnimation.play() for coordinating layout animations across multiple independently-registered elements. This enables Solid/Svelte apps to have individual components register themselves, then trigger animations globally with a single play() call. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove blocking check in add() when currentAnimation exists - Change play() to return existing animation only when no new pending scopes - Auto-clear pending state after play() so new add() calls queue for next batch - Add interruption test to global-collector.html - Update docstrings to reflect new behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: Layout Animation BuilderCritical Issues - Build Breaking 🚨1. Missing Dependencies (Build Failure)The new Line 6: import { getLayoutElements } from "./get-layout-elements"❌ File does not exist: Lines 8-11: import {
buildProjectionTree,
cleanupProjectionTree,
type ProjectionContext,
type BuildProjectionTreeOptions,
} from "./projection-tree"❌ File does not exist: Impact: This PR will fail to build and cannot be merged until these missing files are added. Code Quality Issues2. Redundant Type Casting (line 123)const resolvedScope =
elements.length > 0 ? elements[0] : document
pendingScopes.push({
scope: resolvedScope instanceof Document ? resolvedScope : resolvedScope,
options,
})The ternary Suggestion: Either remove the redundant check or clarify the intended type narrowing: pendingScopes.push({
scope: resolvedScope,
options,
})3. Inconsistent Type Safety (line 94)ease: (options.ease ?? "easeOut") as any,Using Recommendation: Define proper type guards or update the type definitions rather than using type assertions. 4. Variable Shadowing Concern (line 176)pendingScopes = []
pendingRecords = []
snapshotsTaken = false
// Auto-cleanup when animation completes
const capturedContext = context
currentAnimation.finished.then(() => {The closure captures Architecture & Design5. State Management ComplexityThe collector uses multiple boolean flags ( Potential race condition scenario:
Recommendation: Consider using a more explicit state machine (e.g., 6. Memory Leak PreventionLine 187-192: for (const element of capturedContext.nodes.keys()) {
if (!document.contains(element)) {
elementsToCleanup.add(element)
}
}Good defensive programming! However,
7. API Design: Idempotency WindowThe Documentation concern: The JSDoc states:
But it's unclear to users:
Suggestion: Add explicit documentation about the lifecycle and when Performance Considerations8. Synchronous DOM MeasurementsLine 85-86: const allElements = pendingRecords.map((r) => r.element)
context = buildProjectionTree(allElements, context, buildOptions)Building projection trees involves DOM measurements (getBoundingClientRect, etc.). For large element counts, this can cause:
Recommendation: Ensure Testing Coverage9. Test File Quality ✅The HTML test file (
Suggestion: Consider adding:
Security & Safety10. No Security Concerns ✅The code doesn't:
Positive Aspects ✅
Required Actions Before Merge
RecommendationDo not merge until missing dependencies are added. Once the build-breaking issues are resolved, this is a well-designed feature with good test coverage. The architectural concerns are minor and can be addressed in follow-up PRs. Generated by Claude Code review |
No description provided.