[pull] main from motiondivision:main#209
Merged
Conversation
Root cause: Drag constraints are cached and only recalculated on drag start, projection "measure" events, or window resize. When the draggable element resizes via CSS, none of these triggers fire, leaving stale constraints that cause overflow. Fix: Attach ResizeObserver to the draggable element (and optionally the constraint container) to trigger constraint recalculation on size changes. https://claude.ai/code/session_013GYT7zpJ72FuvCdmttfsvU
…izes This fixes an issue where drag constraints would not update when the draggable element's dimensions changed (e.g., via CSS resize), causing the element to overflow its constraint boundaries. The fix adds ResizeObserver to both the draggable element and the constraint container (when using ref-based constraints). When either element resizes, the projection layout is updated and constraints are recalculated. Fixes #2458 https://claude.ai/code/session_013GYT7zpJ72FuvCdmttfsvU
…ment resize Adds a test page and Cypress tests that reproduce the exact behavior from issue #2458: a draggable element with ref-based constraints that gets resized should have its constraints recalculated so it cannot overflow the container. Tests cover: - Constraints work correctly before resize - Constraints update after the draggable element is resized - Constraints update after resize even with a prior drag offset https://claude.ai/code/session_013GYT7zpJ72FuvCdmttfsvU
Ref-based drag constraints require a real layout engine to calculate bounding boxes, which JSDOM doesn't provide. The Cypress E2E test covers this behavior properly in a real browser. https://claude.ai/code/session_013GYT7zpJ72FuvCdmttfsvU
Resolve issues with the initial ResizeObserver fix for #2458: - Skip initial ResizeObserver callbacks (fires on observe()) to prevent corrupting element position on mount - Reset constraints before recalculating in scalePositionWithinConstraints so the cached-constraint guard doesn't prevent fresh measurement - Add render flush after repositioning to prevent visual flash - Skip rebasing for ref-based constraints (already in correct coordinate space) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Each ResizeObserver fires on initial observation. Replace shared counter with per-observer skipFirstCall wrapper so the skip logic doesn't depend on knowing the total number of observed elements. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…-2458-YF8bb Add resize observer support for ref-based drag constraints
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )