-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
onAnimatePlay callback
#3499
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
onAnimatePlay callback
#3499
Conversation
PR Review:
|
This implements the feature requested in issue #2765. The new `onAnimationPlay` callback fires when an animation actually begins playing in the DOM, after any `delay` or `staggerChildren` settings have completed. Key changes: - Add `onDelayComplete` callback to AnimationPlaybackLifecycles - Track delay phase exit in JSAnimation.tick() with hasExitedDelayPhase flag - Add timeout-based delay tracking in NativeAnimation for WAAPI - Thread onDelayComplete through visual-element-target.ts with "fire once" wrapper to ensure it only fires when the first property animation starts - Add AnimationPlay event to VisualElement event system - Add onAnimationPlay prop type with JSDoc documentation - Fire AnimationPlay event for children at their respective delay times - Add tests for the new callback behavior This allows users to know when their animation truly starts, not just when it's queued, which is particularly useful for coordinating UI updates with delayed or staggered animations. Closes #2765
642f1b8 to
ed03f78
Compare
PR Review: onAnimationPlay CallbackThank you for implementing this feature! The implementation addresses the issue raised in #2765. Strengths
Potential Issues1. Typo in PR TitleTitle says onAnimatePlay but implementation uses onAnimationPlay 2. performance.now() in TestsTests use performance.now() but CLAUDE.md recommends time.now() from motion-dom/src/frameloop/sync-time.ts 3. Timing Assertion May Be FlakyTest expects 90ms for 100ms delay - could be flaky on slow CI 4. Race Condition in NativeAnimationPromise.resolve().then() for zero-delay may fire before first frame. Consider requestAnimationFrame 5. Duplicated CleanupConsider extracting clearDelayTimeout() method SuggestionsTest coverage gaps: staggered children, cancellation, repeats, WAAPI Documentation: mention repeat behavior and relationship with onAnimationStart SummarySolid implementation. Main concerns: timing assertions and zero-delay callback timing. Recommend addressing performance.now() usage before merging. |
The isTransitionDefined function determines whether a transition has been explicitly defined by the user. It filters out orchestration and internal options before checking if any properties remain. Adding onDelayComplete to the transition object was causing this function to incorrectly think a transition was defined, which prevented getDefaultTransition from applying the default easing curve [0.25, 0.1, 0.35, 1] for non-transform properties. This fix adds onDelayComplete to the list of filtered properties, restoring the correct behavior where default transitions are applied when no user-defined transition exists.
PR Review:
|
This implements the feature requested in issue #2765. The new
onAnimationPlaycallback fires when an animation actually begins playing in the DOM, after anydelayorstaggerChildrensettings have completed.Key changes:
onDelayCompletecallback to AnimationPlaybackLifecyclesThis allows users to know when their animation truly starts, not just when it's queued, which is particularly useful for coordinating UI updates with delayed or staggered animations.
Closes #2765