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

fix(Text): dont add additional x value for lines #469

Merged
merged 1 commit into from Jan 29, 2019

Conversation

arahansen
Copy link
Contributor

@arahansen arahansen commented Jan 28, 2019

When Text nodes are cloned, the container is copied over, including x offsets for each line. For fixed Text elements, this means that the x value was being accumulated on top of the original rect offset which resulted in this shifting effect that gradually grows worse for each page the fixed element shows up on.

I don't have an exact repro jsx but it would look roughly like this:

<Document>
  <Page>
    {/* Foo shows up fine on the first page, but is shifted to the right 
         8 pixels on subsequent pages 
    */}
    <Text style={{ padding: 8 }} fixed>Foo</Text>
     <LotsOfOtherContent />
  </Page>
</Document>

Before fix:
image

After fix:
image

Fixes #361

@@ -28,4 +34,27 @@ describe('Text', () => {
expect(text.layoutEngine.layout.mock.calls).toHaveLength(1);
expect(text.layoutEngine.layout.mock.calls[0][0].string).toBe('');
});

test('Should render the same rect x value for clones', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont love how this test is constructed. Let me know if you have a better means to test this!

Copy link
Owner

Choose a reason for hiding this comment

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

I think is fine! Maybe there's a simpler way, but this is not bad either. Thank you very much!

@@ -28,4 +34,27 @@ describe('Text', () => {
expect(text.layoutEngine.layout.mock.calls).toHaveLength(1);
expect(text.layoutEngine.layout.mock.calls[0][0].string).toBe('');
});

test('Should render the same rect x value for clones', async () => {
Copy link
Owner

Choose a reason for hiding this comment

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

I think is fine! Maybe there's a simpler way, but this is not bad either. Thank you very much!

@diegomura diegomura merged commit b58be53 into diegomura:master Jan 29, 2019
@arahansen arahansen deleted the fix-clone-text branch January 29, 2019 18:00
@arahansen
Copy link
Contributor Author

would it be possible to get a release cut that includes this change? Would love to integrate this back into my project 🙂

@diegomura
Copy link
Owner

Definitely! I will release a new fix today. Sorry about the delay

@arahansen
Copy link
Contributor Author

No worries, I really appreciate your responsiveness and help getting started with the project!

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

Successfully merging this pull request may close these issues.

Children of fixed View offsets unexpectedly
2 participants