Fix for negative spacing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ref, computed, type Ref, type ComputedRef } from 'vue';
|
||||
import type { Sprite } from '@/types/sprites';
|
||||
import { getMaxDimensions } from './useSprites';
|
||||
import { calculateNegativeSpacing } from './useNegativeSpacing';
|
||||
|
||||
export interface CellPosition {
|
||||
col: number;
|
||||
@@ -74,17 +75,8 @@ export function useDragSprite(options: DragSpriteOptions) {
|
||||
lastMaxWidth.value = baseMaxWidth;
|
||||
lastMaxHeight.value = baseMaxHeight;
|
||||
|
||||
// Calculate negative spacing based on sprite size differences
|
||||
let negativeSpacing = 0;
|
||||
if (negativeSpacingEnabled && sprites.length > 0) {
|
||||
// Find the smallest sprite dimensions
|
||||
const minWidth = Math.min(...sprites.map(s => s.width));
|
||||
const minHeight = Math.min(...sprites.map(s => s.height));
|
||||
// Negative spacing is the difference between max and min dimensions
|
||||
const widthDiff = baseMaxWidth - minWidth;
|
||||
const heightDiff = baseMaxHeight - minHeight;
|
||||
negativeSpacing = Math.max(widthDiff, heightDiff);
|
||||
}
|
||||
// Calculate negative spacing using shared composable
|
||||
const negativeSpacing = calculateNegativeSpacing(sprites, negativeSpacingEnabled);
|
||||
|
||||
// Add negative spacing to expand each cell
|
||||
const maxWidth = baseMaxWidth + negativeSpacing;
|
||||
|
||||
Reference in New Issue
Block a user