[#126.1] Fix jumping effect on initial layout by using lazy initialization#129
Open
thomasnemer wants to merge 1 commit intomainfrom
Open
[#126.1] Fix jumping effect on initial layout by using lazy initialization#129thomasnemer wants to merge 1 commit intomainfrom
thomasnemer wants to merge 1 commit intomainfrom
Conversation
…ation Fixes the "jumping effect" where components created with partial sizes (e.g., width=300, height=0) would capture height=0 as "original" when setAxisResizeBehavior() was called before layout ran. **Root Cause:** setAxisResizeBehavior() was initializing originalWidth/originalHeight immediately when called, before FlexLayout had a chance to set proper dimensions. This caused FIXED axis behavior to use incorrect baseline values (e.g., originalHeight=0) on first resize. **Solution:** Removed early initialization from setAxisResizeBehavior(). Now originalWidth/originalHeight are lazily initialized on the FIRST call to onParentResize(), which happens AFTER layout has set proper sizes. **Result:** - Initial layout matches post-resize layout - No visual "jumping" on first window resize - All resizes use consistent, correct baseline dimensions **Test Coverage:** Added test_init_order_bug.cpp to verify: - First resize uses correct dimensions (300x600) - Subsequent resizes maintain consistency (300x768, 300x480) - No jumping effect across multiple resize operations Resolves: #126
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.
Summary
Fixes the "jumping effect" described in issue #126 where components would appear with incorrect dimensions on initial layout, then "snap" to correct layout on the first window resize.
Root Cause
setAxisResizeBehavior()was initializingoriginalWidth/originalHeightimmediately when called, before FlexLayout had a chance to set proper dimensions. This caused components created with partial sizes (e.g.,withSize(300, 0)) to captureoriginalHeight=0as their "original" dimension.When the first window resize occurred, the FIXED/FILL axis behaviors would use these incorrect baseline values, causing the layout to differ from the initial state.
Solution
setAxisResizeBehavior()originalWidth/originalHeightare now initialized on the first call toonParentResize(), which happens AFTER layout has set proper sizessetBounds()already had fallback logic using current dimensions when original dimensions are 0Changes
Core Fix
include/bombfork/prong/core/component.h: Removed initialization block fromsetAxisResizeBehavior(), added detailed comments explaining the lazy initialization approachTest Coverage
tests/test_init_order_bug.cpp: New comprehensive test that verifies:Test Results
All existing tests pass:
New test output:
Manual Testing
Related Issues
Notes
This is a minimal, surgical fix that addresses the root cause without requiring broader architectural changes. The existing
onParentResize()initialization logic already handled this correctly - we just needed to stop initializing too early.