Fixed rounding issues with YGRoundValueToPixelGrid and negative floats #702
Reference in New Issue
Block a user
No description provided.
Delete Branch "Edensan/edensan"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While implementing Yoga into a custom framework I found out that sizes of objects that had been layout with Yoga were sometimes 1px smaller/bigger than expected, causing all sorts of unexpected logic to trigger.
Turns out the culprit was YGRoundValueToPixelGrid.
It was computing values regardless of sign and thus negative inputs were outputting unexpected results (eg. if scaledValue == -0.6f closest rounding should be -1.0f but would be 0.0f instead).
I have updated the code to handle positive and negative values symmetrically in order to ensure that two values with a same offset between them will conserve the offset during animations regardless of the rounding type.
Please check the test cases to confirm the logic.
LGTM. The tests you added were really helpful in understanding the issue!
This looks like it's covering the same issue as https://github.com/facebook/yoga/pull/688. I'd really like to see one of these merged in as I'm being forced to use a fork of this project due to this issue. Does anyone have an update on this?
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.