Skip to content
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

Fixed rounding issues with YGRoundValueToPixelGrid and negative floats #702

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Edensan
Copy link

@Edensan Edensan commented Jan 24, 2018

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.

Copy link

@matthargett matthargett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The tests you added were really helpful in understanding the issue!

@lunarraid
Copy link

This looks like it's covering the same issue as #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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants