layout
Organize and layout items based on various algorithms
Getting Started
Install the module with: npm install layout
var layout = require('layout');
var layer = layout('top-down');
layer.addItem({'height': 20, 'width': 10, 'meta': 'medium'});
layer.addItem({'height': 10, 'width': 10, 'meta': 'small'});
layer.addItem({'height': 50, 'width': 40, 'meta': 'large'});
var info = layer['export']();
{
height: 80,
width: 40,
items: [{
height: 10,
width: 10,
meta: 'small',
x: 0,
y: 0
}, {
height: 20,
width: 10,
meta: 'medium',
x: 0,
y: 10
}, {
height: 50,
width: 40,
meta: 'large',
x: 0,
y: 30
}]
}
Documentation
Layout is a constructor function
Items can be added via addItem
which are required to have a height
and width
. Any additional info should be stored inside of meta
.
export
is how you take your items and organize them.
Custom algorithms
You can add your own algorithm via layout.addAlgorithm
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Donating
Support this project and others by twolfson via gittip.
License
Copyright (c) 2012 Todd Wolfson
Licensed under the MIT license.