1

I have been playing around with famo.us and am currently stuck at getting dynamic content to scroll inside a scrollview/surface

I currently have a scrollview with one surface and on render of the content i check the size of the content and set the same height to the surface. I do the same on resize.

I was wondering if there is a better solution with famo.us to handle surfaces with dynamic content within a scrollview.

Code is basically boilerplate so no examples here. It's more of a "is it possible" question.

Marc vd M
  • 354
  • 3
  • 11

1 Answers1

1

Currently there is no easier way to do it. When you say dynamic content I assume you are talking about a true-sized object. I see you mentioned checking the height on render, which again has been a solution before Famo.us makes this more accessible.

I have achieved dynamic content inside a sequentialLayout by creating a Custom View object that takes the same parameters as Surface. The view then creates a frontView that is visible and a backView that is not. If a size parameter comes in at [500,true] for example, backView will take the true-sizing and frontView will calculate the actual size in pixels. Then on resize, we can use backView as a sort of ruler, to do the dynamic sizing, while updates to the actual height in pixels are applied to frontView.

http://higherorderhuman.com/examples/dynamicContent.html

This sort of thing does seem harder than it should be, but that's because this behavior is a strength of the traditional box model. By throwing out the box model, we benefit in many other areas, but this is not one of them!

johntraver
  • 3,612
  • 18
  • 17
  • Thanks for the quick response. I was hoping that i overlooked it or missed it in the docs. I hope it will be included soon as i am working on a news app which has news items that can be a small or long depending on the news :P they should have a pipe or something that listens to the height of the surface and adjust the scrollview accordingly. – Marc vd M May 05 '14 at 17:21
  • Something like if the surface size changes it should pipe that to the parent scrollview which can act on it and change its height/width – Marc vd M May 05 '14 at 17:23
  • Yes, I would hope such a thing will be possible soon. You could certainly create such an event that emits when the size is changed on a surface, but again it will be a hack for a custom surface. The initial bug was filed because this limitation affects many other origin and positioning problems. I believe they will have a solution soon. – johntraver May 05 '14 at 17:52