[FEAT] Format code
This commit is contained in:
@@ -113,18 +113,15 @@ export function useDragSprite(options: DragSpriteOptions) {
|
||||
});
|
||||
|
||||
const findCellAtPosition = (x: number, y: number): CellPosition | null => {
|
||||
const sprites = getSprites();
|
||||
const columns = getColumns();
|
||||
const { maxWidth, maxHeight } = calculateMaxDimensions();
|
||||
const col = Math.floor(x / maxWidth);
|
||||
const row = Math.floor(y / maxHeight);
|
||||
|
||||
const totalRows = Math.ceil(sprites.length / columns);
|
||||
if (col >= 0 && col < columns && row >= 0 && row < totalRows) {
|
||||
// Allow dropping anywhere in the columns, assuming infinite rows effectively
|
||||
if (col >= 0 && col < columns && row >= 0) {
|
||||
const index = row * columns + col;
|
||||
if (index < sprites.length) {
|
||||
return { col, row, index };
|
||||
}
|
||||
return { col, row, index };
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user