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

If the measure function is defined: only return from execution of lay… #84

Merged
merged 1 commit into from
May 14, 2015
Merged

If the measure function is defined: only return from execution of lay… #84

merged 1 commit into from
May 14, 2015

Conversation

lukasredev
Copy link
Contributor

…outNode, when the node has no children.

I'am currently working on a new implementation of the TextView element in react-native.
My implementation uses the node->measure function to calculate the height of the element, but a TextView may also have subviews. If thats the case it's necessary to execute the rest of the layoutNode function and not stopping it after line 318.
This change does not affect the behaviour of the other module ( RCText ), that uses the measure function, because this element will always have a children_count of zero.

vjeux added a commit that referenced this pull request May 14, 2015
If the measure function is defined: only return from execution of lay…
@vjeux vjeux merged commit c3a2ddc into facebook:master May 14, 2015
@vjeux
Copy link
Contributor

vjeux commented May 14, 2015

Thanks, that makes sense! I can't wait to see your TextView code. I've always wanted to be able to put arbitrary elements there but couldn't find time to implement it!

paramaggarwal added a commit to paramaggarwal/react-native that referenced this pull request Jun 29, 2015
paramaggarwal added a commit to paramaggarwal/react-native that referenced this pull request Jun 29, 2015
paramaggarwal added a commit to paramaggarwal/react-native that referenced this pull request Aug 28, 2015
@paramaggarwal
Copy link
Contributor

@lukasreichart Just like you use this for a <TextView>, I use it for <Image>. With measure I'm able to define an aspect ratio for the image and then have it take the entire width of the device - taking the necessary height as required. With the changes in this PR, I can also have children of the <Image> and have everything work perfectly. Super useful!

Not sure how to add support to use measure the other way round - calculate width given a height.

@lukasredev
Copy link
Contributor Author

@paramaggarwal sounds great and I'd love to try it. 👍 Have you published a npm module or created a PR for react-native?

@paramaggarwal
Copy link
Contributor

@lukasreichart Unfortunately your change here hasn't ended up in RN yet... Open PR: facebook/react-native#1776

I have a generic implementation for all RCTView subclasses here: facebook/react-native#1538 - simply pass an aspectRatio prop to your views. So you could make any view behave like a rigid boxed rectangle and all the children would layout normally.

The PR is blocked at the moment as measure can only calculate a height given a width and not vice-versa. Any thoughts on how to make measure more generic to be able to measure both ways?

paramaggarwal added a commit to paramaggarwal/react-native that referenced this pull request Sep 2, 2015
paramaggarwal added a commit to paramaggarwal/react-native that referenced this pull request Sep 15, 2015
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.

3 participants