I don't think I understand what it means to size a famo.us node with a true
size.
In this example, I'm just trying to center a View with a fixed size. But I eventually want these BlueView's to calculate their size based on their content, and have an array of them in a Scrollview.
So, I guess my questions are:
What does true
size really mean? What's the math behind it? I'm assuming that a size of true
triggers the node, blueModifier
, to get that value from its direct child node, in this case my blueView
instance. Am I wrong?
If that is the case, how to I get BlueView's to publish their size? Reading the famo.us source and their documentation is just confusing. It looks like if a View
has just a single child, it should use that child's size. Or you can use setOptions()
on a view to set its size. Or you can override a views getSize()
function. But I can't get any of those to work.
function BlueView() {
View.call(this)
this
.add(new Modifier({
size: [400, 200],
origin: [0, 0],
align: [0, 0]
}))
.add(new Surface({
properties: {
backgroundColor: 'blue'
}
}));
};
BlueView.prototype = Object.create(View.prototype);
BlueView.prototype.constructor = BlueView;
var blueModifier = new Modifier({
size: [true, true],
origin: [0.5, 0.5],
align: [0.5, 0.5],
});
var blueView = new BlueView();
mainContext.add(blueModifier).add(blueView);