Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const createLayouts = layouts => {
createLayout(layouts[0].layoutParams); //warmup
console.time(
`Created ${numberOfRuns} Layouts with ${numberOfImages} images. It took: `
);
const startTime = Date.now();
for (let i = 0; i < numberOfRuns; i++) {
createLayout(layouts[i].layoutParams);
}
const duration = Date.now() - startTime;
console.timeEnd(
`Created ${numberOfRuns} Layouts with ${numberOfImages} images. It took: `
);
return duration;
};
itemSpacing: 20,
allowedGroupTypes: ['1', '2v', '3v']
//add more style params here
};
const container = {
width: window.innerWidth,
height: window.innerHeight
};
const layoutParams = {
items,
styleParams,
container
};
const layout = createLayout(layoutParams);
const parent = document.createElement('div');
parent.id = 'root';
document.body.prepend(parent);
for (let i = 0; i < layout.items.length; i++) {
const item = layout.items[i].scheme;
const iDom = document.createElement('div');
iDom.innerHTML = i;
iDom.style.width = item.width + 'px';
iDom.style.height = item.height + 'px';
iDom.style.position = 'absolute';
iDom.style.top = item.offset.top + 'px';
iDom.style.left = item.offset.left + 'px';
iDom.style.backgroundColor = items[i].bgColor;
parent.prepend(iDom);
}
isColumnsLayout: false,
itemSpacing: 20
//add more style params here
};
const container = {
width: window.innerWidth,
height: window.innerHeight
};
const layoutParams = {
items,
styleParams,
container
};
const layout = createLayout(layoutParams);
const parent = document.createElement('div');
parent.id = 'root';
document.body.prepend(parent);
document.body.style.margin = '-' + styleParams.itemSpacing + 'px';
document.body.style.padding = 0;
for (let column, c = 0; column = layout.columns[c]; c++) {
const cDom = document.createElement('div');
cDom.id = 'column';
cDom.style.width = layout.colWidth + 'px';
cDom.style.float = 'left';
cDom.style.position = 'relative';
parent.prepend(cDom);
for (let group, g = 0; group = column[g]; g++) {
const gDom = document.createElement('div');
const cssLayouts = widths.map(width => {
const _layoutParams = {
...layoutParams,
...{
container: { ...layoutParams.container, galleryWidth: width, width },
},
};
return createLayout(_layoutParams);
});
return createCssFromLayouts(galleryDomId, cssLayouts, layoutParams.styleParams, widths);