It seems I'm a bit confused as to how the render tree works, or more specifically how modifiers affect their descendants.
For example, if I have a render tree that looks like:
-------------------
| Global Modifier |
-------------------
|
---------------------------------------
| | |
---------------- ---------------- --------------------
| Blue Surface | | Top Left Mod | | Bottom Right Mod |
---------------- ---------------- --------------------
| |
----------------- ---------------
| Green Surface | | Red Surface |
----------------- ---------------
- The global modifier sets the overall size.
- The blue surface fills the space.
- And the top-left and bottom-right modifiers have smaller sizes and use
origin
andalign
to align their child surfaces to in the corners.
So far, so good. It all works well. But if I put a transform on the global modifier, rotating it, for example, what I would expect would be for the whole unit to rotate, but instead it looks like each of my three surfaces are rotating independently around their own origins.
Why is it doing that?
How do I turn this into a unit that I can manipulate as a whole?
Thanks.
Here's some code:
http://jsfiddle.net/scucLw0h/1/
var Surface = famous.core.Surface;
var View = famous.core.View;
var Modifier = famous.core.Modifier;
var StateModifier = famous.modifiers.StateModifier;
var Engine = famous.core.Engine;
var Transform = famous.core.Transform;
var Transitionable = famous.core.Transitionable;
var globalModifier = new StateModifier({
size: [100, 100],
origin: [.5, .5],
align: [.5, .5]
});
var topLeftModifier = new Modifier({
size: [50, 50],
align: [0, 0],
origin: [0, 0]
});
var bottomRightModifier = new Modifier({
size: [50, 50],
align: [1, 1],
origin: [1, 1]
});
var blueSurface = new Surface({
properties: {
backgroundColor: 'blue'
}
});
var redSurface = new Surface({
properties: {
backgroundColor: 'red'
}
});
var greenSurface = new Surface({
properties: {
backgroundColor: 'green'
}
});
var mainContext = Engine.createContext();
var globalContext = mainContext.add(globalModifier);
globalContext.add(blueSurface);
globalContext.add(topLeftModifier).add(greenSurface);
globalContext.add(bottomRightModifier).add(redSurface);
globalModifier.setTransform(Transform.rotate(0, 45, 0), {duration: 1000});