Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sasza2 committed May 13, 2024
1 parent 8b78e4e commit 565dbf0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/hooks/useOrganizeElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const useOrganizeElements = () => {
const elementsRef = useRef<typeof elements>();
elementsRef.current = elements;

const onOrganizeElements = useCallback((selectedElements: GridElement[] = [], options?: OrganizeElementsOptions): GridElement[] => {
const onOrganizeElements = useCallback((
selectedElements: GridElement[] = [],
options: OrganizeElementsOptions = {},
): GridElement[] => {
elementsHeightRef.current = {};
const panZoomElementsRef = panZoomRef.current.getElements();

Expand All @@ -51,14 +54,14 @@ const useOrganizeElements = () => {
});

const internalMeasureElementHeight = (element: GridElement) => {
let height = measureElementHeight(element)
let height = measureElementHeight(element);

if (options?.marginBottomAtElements[element.id]) {
height += options?.marginBottomAtElements[element.id]
if (options && options.marginBottomAtElements && options.marginBottomAtElements[element.id]) {
height += options.marginBottomAtElements[element.id];
}

return height
}
return height;
};

const nextElements = organizeGridElements({
startingElements: elementsRef.current,
Expand All @@ -77,7 +80,7 @@ const useOrganizeElements = () => {

hasCollision.current = false;

return nextElements
return nextElements;
}, [cols, colWidth, elements, gapHorizontal, gapVertical, paddingLeft, rows, rowHeight]);

return onOrganizeElements;
Expand Down

0 comments on commit 565dbf0

Please sign in to comment.