If the measure function is defined: only return from execution of lay… #84
Reference in New Issue
Block a user
No description provided.
Delete Branch "master"
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?
…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.
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!
@lukasreichart Just like you use this for a
<TextView>
, I use it for<Image>
. Withmeasure
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.@paramaggarwal sounds great and I'd love to try it. 👍 Have you published a npm module or created a PR for react-native?
@lukasreichart Unfortunately your change here hasn't ended up in RN yet... Open PR: https://github.com/facebook/react-native/pull/1776
I have a generic implementation for all RCTView subclasses here: https://github.com/facebook/react-native/pull/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 makemeasure
more generic to be able to measure both ways?