Skip to content

Commit

Permalink
fix the problem if layout doesnt have static item
Browse files Browse the repository at this point in the history
  • Loading branch information
allisYuTing committed Dec 25, 2023
1 parent e6567f6 commit dc3ca7c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ export function collides(l1: ILayoutItem, l2: ILayoutItem): boolean {
* @throws {Error} Empty layout.
*/
export function getFirstCollision(layout: TLayout, layoutItem: ILayoutItem): ILayoutItem | undefined {
if(layout.length < 1) {
throw new Error('Empty layout');
}
// if layout doesnt have static item it will cause error
// cannot drag or do anything

// if(layout.length < 1) {
// throw new Error('Empty layout');
// }

for(let i = 0, len = layout.length; i < len; i++) {
if(collides(layout[i], layoutItem)) {
Expand Down

0 comments on commit dc3ca7c

Please sign in to comment.