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

Merged
lukasredev merged 1 commits from master into master 2015-05-14 08:48:04 -07:00
lukasredev commented 2015-05-10 08:47:47 -07:00 (Migrated from github.com)

…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.

…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 commented 2015-05-14 08:48:44 -07:00 (Migrated from github.com)

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!

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 commented 2015-08-28 08:59:50 -07:00 (Migrated from github.com)

@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.

@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 commented 2015-08-28 09:40:27 -07:00 (Migrated from github.com)

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

@paramaggarwal sounds great and I'd love to try it. :+1: Have you published a npm module or created a PR for react-native?
paramaggarwal commented 2015-08-28 09:56:20 -07:00 (Migrated from github.com)

@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 make measure more generic to be able to measure both ways?

@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 make `measure` more generic to be able to measure both ways?
Sign in to join this conversation.
No description provided.