Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// Generated, do not edit. sha256:0de0d7d8274e0483bbf9a739f8fbd821c59be413f9db532018d5a830258c7352
|
||||
import { DASHBOARD } from '../../shared/config.js';
|
||||
|
||||
export function freeRunAt(layout, col, row, stepsOf) {
|
||||
const cols = DASHBOARD.GRID_COLUMNS;
|
||||
if (!Number.isInteger(col) || !Number.isInteger(row) || col < 0 || col >= cols || row < 0) return null;
|
||||
const taken = x => layout.some(it => x >= it.x && x < it.x + it.w && row >= it.y && row < it.y + stepsOf(it));
|
||||
if (taken(col)) return null;
|
||||
let x0 = col, x1 = col + 1;
|
||||
while (x0 > 0 && !taken(x0 - 1)) x0--;
|
||||
while (x1 < cols && !taken(x1)) x1++;
|
||||
return { x: x0, y: row, w: x1 - x0, col };
|
||||
}
|
||||
|
||||
export function fittingCatalog(catalog, run) {
|
||||
return catalog.filter(c => {
|
||||
const def = DASHBOARD.WIDGETS[c.type];
|
||||
return def && run && def.defaultSpan <= run.w;
|
||||
});
|
||||
}
|
||||
|
||||
export function placeInRun(run, w) {
|
||||
return { x: Math.max(run.x, Math.min(run.col, run.x + run.w - w)), y: run.y };
|
||||
}
|
||||
Reference in new issue
Block a user