Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top