fix: smooth canvas resizing during CSS transitions (#3604)fix: smooth canvas resizing during CSS transitions (#3604) #3605
+40
−2
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.
Description
Fixes #3604 - Canvas element expands smoothly during CSS transitions, but 3D rendering now resizes smoothly instead of snapping to the final size.
Root Cause
The
useMeasurehook usesResizeObserver, which typically only fires at the beginning and end of CSS transitions, not during intermediate frames. This caused the 3D rendering to update only after transitions completed.Solution
Added continuous size polling using
requestAnimationFrameto detect size changes on every frame during CSS transitions:Changes
RootStoreimport and ref to track the storecontainerElementRefto access container DOM elementuseEffectwithrequestAnimationFrameloop for continuous size checkinguseMeasurecallback and our refTesting
✅ All existing canvas tests pass without regressions:
Notes
Manual testing is required to verify smooth transitions with actual CSS animations, as this is a visual/timing issue that cannot be reliably tested in automated unit tests.- Add continuous size polling using requestAnimationFrame