* Move existing canvas's to CanvasArenas folder * moving hooks to canvas arenas folder. * Sticky canvas implementation. * fixing specs(WIP) * dip * fixing test cases. * removing comments. * fixing build * renaming for readability. * adding folder for canvas based sagas. * Resolve conflicts. * fixing failed cases. * fixing cypress cases. * fixing bugs introduced coz of drag and drop. * fixing bugs. * few more bug fixes in draw to select. * mouse pointer default when drag to select. * bug fix. * dip * integrating intersection api. * dip need to adjust offset * fixing offset issues. * readability fix * rebase bug fixes. * bug fix. * adjust canvas slider on mouse over. * unwanted changes. * left offset fix + removing dead code. * fixing bugs. * fixing broken test cases. * addressing code review comments.
25 lines
805 B
TypeScript
25 lines
805 B
TypeScript
import { OccupiedSpace } from "constants/CanvasEditorConstants";
|
|
import { GridDefaults } from "constants/WidgetConstants";
|
|
|
|
export const calculateDropTargetRows = (
|
|
widgetIdsToExclude: string[],
|
|
widgetBottomRow: number,
|
|
defaultRows: number,
|
|
occupiedSpacesByChildren?: OccupiedSpace[],
|
|
) => {
|
|
/* Max bottom row including the existing widgets as well as the widget we just dropped */
|
|
let minBottomRow = widgetBottomRow;
|
|
if (occupiedSpacesByChildren) {
|
|
minBottomRow = occupiedSpacesByChildren.reduce((prev, next) => {
|
|
if (!widgetIdsToExclude.includes(next.id)) {
|
|
return next.bottom > prev ? next.bottom : prev;
|
|
}
|
|
return prev;
|
|
}, widgetBottomRow);
|
|
}
|
|
|
|
return Math.ceil(
|
|
Math.max(minBottomRow + GridDefaults.CANVAS_EXTENSION_OFFSET, defaultRows),
|
|
);
|
|
};
|