Question

I am trying to add a image below a scrollview using the famous sequentialLayout and im having a problem with the scrollview's height.

This is how i create my scrollview.

var scrollview = new Scrollview({       
    direction: Utility.Direction.X,
    options: {
        size: [300, 300]
    },        
    paginated: true
});

When i add surfaces to the scrollview with 250 height, the scrollview's parent DOM container (famous-group) containing these surfaces has a width and height of 0.

When adding this scrollview within a sequentialLayout as the first item, the second item or surface with a height is displayed on top of this scrollview since it has no height.

Any ideas how to fix this using Famo.us?

Was it helpful?

Solution

You can't set size like that - use a modifier for this.

This will be the render tree

MainContext
   SequentialLayout
      Modifier(size)
          ScrollView
      Modifier(size)
          Image

Code snippet:

// Create components
var scrollview = new ScrollView();
var image = new ImageSurface({
    content: 'content/images/famous_symbol_transparent.png'
});

// Create Size Modifiers
var scrollModifier = new StateModifier({ size: [200,200]});
var imageModifier = new StateModifier({ size: [200,200]});

// Wrap the Modifier in a RenderNode, so we can add the surface
// (you can't add surfaces directly to a modifier)
var scrollNode = new RenderNode(scrollModifier)
scrollNode.add(scrollview);

var imageNode = new RenderNode(imageModifier);
imageNode.add(image);

// Create a SequentialLayout
var sequence = new SequentialLayout();
sequence.sequenceFrom([scrollNode,imageNode]);

And here is an example gist (copy-paste the main.js after running the yo famous generator)

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