Getting the content dimensions of an overflow hidden/scroll node #623

Open
opened 2017-09-10 14:01:23 -07:00 by ubald · 5 comments
ubald commented 2017-09-10 14:01:23 -07:00 (Migrated from github.com)

Hi, I am wondering how to get the content dimensions of a node when its overflow property is set to hidden or scroll. Of course I can iterate over the children and find out myself, but I assume Yoga already has that information from the layout calculations.

Thanks.

Hi, I am wondering how to get the content dimensions of a node when its `overflow` property is set to `hidden` or `scroll`. Of course I can iterate over the children and find out myself, but I assume Yoga already has that information from the layout calculations. Thanks.
LeoSchleicher commented 2017-09-11 00:43:33 -07:00 (Migrated from github.com)

In iOS I make whole layout calculation first, then ask for dimensions of scrollable/hidden root element, then set scrollable size of containing ScrollView via setContentSize to root element dimensions

In iOS I make whole layout calculation first, then ask for dimensions of scrollable/hidden root element, then set scrollable size of containing ScrollView via setContentSize to root element dimensions
ubald commented 2017-09-11 10:24:18 -07:00 (Migrated from github.com)

@LeoSchleicher I'm using the C version and implementting my own "scroll view" and scrollbars, so I need to know how much is shown (the overflow node's dimensions) versus the content's dimensions as if not clipped by the overflow.

@LeoSchleicher I'm using the C version and implementting my own "scroll view" and scrollbars, so I need to know how much is shown (the overflow node's dimensions) versus the content's dimensions as if not clipped by the overflow.
LeoSchleicher commented 2017-09-12 00:46:19 -07:00 (Migrated from github.com)

I think this is the same situation. So after first layout pass you can get sizes of scroll view and scrollable content view, then apply the sizes to scrollbars control. You can get layout size simply putting all the chindren into one container (scroll pane or something alike) then asking for it's size after applying layout calculation.

I think this is the same situation. So after first layout pass you can get sizes of scroll view and scrollable content view, then apply the sizes to scrollbars control. You can get layout size simply putting all the chindren into one container (scroll pane or something alike) then asking for it's size after applying layout calculation.
ubald commented 2017-09-12 10:28:38 -07:00 (Migrated from github.com)

Ok, I see what you meant. But I don't have that intermediate container, when a node is scrollable, I just clip and translate by the scroll position when drawing them (I use Skia for rendering). Anyway, I ended up calculating the bounds by iterating on all children since I already needed that to get the node's bounds when using absolutely positioned nodes.

Ok, I see what you meant. But I don't have that intermediate container, when a node is scrollable, I just clip and translate by the scroll position when drawing them (I use Skia for rendering). Anyway, I ended up calculating the bounds by iterating on all children since I already needed that to get the node's bounds when using absolutely positioned nodes.
natinusala commented 2020-11-07 08:08:10 -08:00 (Migrated from github.com)

Hi, I'm running in the same scenario as you where I'd like to scroll one node and I cannot get its actual height as it appears to just return the parent height (so it doesn't actually overflow). I set the shrink factor of the node to 0 to make it overflow, maybe that is where I'm wrong?

I would like to avoid counting the height myself by iterating over children because it breaks the abstraction of my scrolling system, which is "take a node and make it scroll", regardless of its direction or children count. The scrolling node might not even have children itself.

Is there a solution to this problem? Maybe something new introduced in some newer Yoga update?

Thanks a bunch!

Hi, I'm running in the same scenario as you where I'd like to scroll one node and I cannot get its actual height as it appears to just return the parent height (so it doesn't actually overflow). I set the shrink factor of the node to 0 to make it overflow, maybe that is where I'm wrong? I would like to avoid counting the height myself by iterating over children because it breaks the abstraction of my scrolling system, which is "take a node and make it scroll", regardless of its direction or children count. The scrolling node might not even have children itself. Is there a solution to this problem? Maybe something new introduced in some newer Yoga update? Thanks a bunch!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#623
No description provided.