Famo.us Scrollview height

流过昼夜 提交于 2019-12-07 15:14:23

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/23057349/famo-us-scrollview-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!