/**
* Loader for Row based Layouts
*
* @author rhess <robin.hess@awi.de>
* @author sjaswal <shahzeib.jaswal@awi.de>
*/
/**
* A function that loads the RowLayout
*
* @memberof vef.viewer.loader
*
* @param {object} options
* @param {Viewer} viewer
*/
export function RowLayout(options, viewer) {
const container = document.createElement("div");
container.style.width = "100%";
container.style.height = "100%";
container.style.display = "flex";
container.style.flexDirection = (options.direction == "column") ? "column": "row";
for (let i = 0; i < options.children.length; ++i) {
const child = document.createElement("div");
child.style.position = "relative";
if (options.direction == "column") {
child.style.width = "100%";
child.style.height = Math.floor(100 / options.children.length) + "%";
} else {
child.style.width = Math.floor(100 / options.children.length) + "%";
child.style.height = "100%";
}
container.appendChild(child);
viewer.addElement(options.children[i], child);
}
viewer.addElement(options.id, container);
}