LayoutDockHelper helps positioning nodes using docking principles.
Example:
var LayoutDockHelper = require('famous-flex/helpers/LayoutDockHelper');
function HeaderFooterLayout(context, options) {
var dock = new LayoutDockHelper(context);
dock.top('header', options.headerSize);
dock.bottom('footer', options.footerSize);
dock.fill('content');
};
You can also use layout-literals to create layouts using docking semantics:
var layoutController = new LayoutController({
layout: {dock: [
['top', 'header', 40],
['bottom', 'footer', 40, 1], // z-index +1
['fill', 'content']
]},
dataSource: {
header: new Surface({content: 'header'}),
footer: new Surface({content: 'footer'}),
content: new Surface({content: 'content'}),
}
});
- LayoutDockHelper
- LayoutDockHelper ⏏
- new LayoutDockHelper(context, [options])
- .parse(data)
- .top([node], [height], [z]) ⇒
LayoutDockHelper
- .left([node], [width], [z]) ⇒
LayoutDockHelper
- .bottom([node], [height], [z]) ⇒
LayoutDockHelper
- .right([node], [width], [z]) ⇒
LayoutDockHelper
- .fill(node, [z]) ⇒
LayoutDockHelper
- .margins(margins) ⇒
LayoutDockHelper
- .get() ⇒
Object
- LayoutDockHelper ⏏
Param | Type | Description |
---|---|---|
context | LayoutContext |
layout-context |
[options] | Object |
additional options |
[options.margins] | Object |
margins to start out with (default: 0px) |
[options.translateZ] | Number |
z-index to use when translating objects (default: 0) |
Parses the layout-rules based on a JSON data object.
The object should be an array with the following syntax:
[[rule, node, value, z], [rule, node, value, z], ...]
Example:
[
['top', 'header', 50],
['bottom', 'footer', 50, 10], // z-index: 10
['margins', [10, 5]], // marginate remaining space: 10px top/bottom, 5px left/right
['fill', 'content']
]
Kind: instance method of LayoutDockHelper
Param | Type | Description |
---|---|---|
data | Object |
JSON object |
Dock the node to the top.
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
[node] | LayoutNode | String |
layout-node to dock, when omitted the height argument argument is used for padding |
[height] | Number |
height of the layout-node, when omitted the height of the node is used |
[z] | Number |
z-index to use for the node |
Dock the node to the left
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
[node] | LayoutNode | String |
layout-node to dock, when omitted the width argument argument is used for padding |
[width] | Number |
width of the layout-node, when omitted the width of the node is used |
[z] | Number |
z-index to use for the node |
Dock the node to the bottom
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
[node] | LayoutNode | String |
layout-node to dock, when omitted the height argument argument is used for padding |
[height] | Number |
height of the layout-node, when omitted the height of the node is used |
[z] | Number |
z-index to use for the node |
Dock the node to the right.
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
[node] | LayoutNode | String |
layout-node to dock, when omitted the width argument argument is used for padding |
[width] | Number |
width of the layout-node, when omitted the width of the node is used |
[z] | Number |
z-index to use for the node |
Fills the node to the remaining content.
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
node | LayoutNode | String |
layout-node to dock |
[z] | Number |
z-index to use for the node |
Applies indent margins to the remaining content.
Kind: instance method of LayoutDockHelper
Returns: LayoutDockHelper
- this
Param | Type | Description |
---|---|---|
margins | Number | Array |
margins shorthand (e.g. '5', [10, 10], [5, 10, 5, 10]) |
Gets the current left/right/top/bottom/z bounds used by the dock-helper.
Kind: instance method of LayoutDockHelper
Returns: Object
- {left: x, right: x, top: x, bottom: x, z: x}