|
|
@ -134,18 +134,13 @@ export default class Dimension { |
|
|
position: number, |
|
|
position: number, |
|
|
config: DroppableZoneConfig, |
|
|
config: DroppableZoneConfig, |
|
|
): { newSize: number; newPosition: number } { |
|
|
): { newSize: number; newPosition: number } { |
|
|
const { ratio, minDroppableDimension, maxUndroppableDimension } = config; |
|
|
const { ratio, minUndroppableDimension: minUnDroppableDimension, maxUndroppableDimension } = config; |
|
|
|
|
|
|
|
|
// Calculate the desired new size based on the ratio, ensuring it doesn't go below minDroppable
|
|
|
let undroppableDimension = (size * (1 - ratio)) / 2; |
|
|
const minSize = Math.min(size, minDroppableDimension); |
|
|
undroppableDimension = Math.max(undroppableDimension, minUnDroppableDimension); |
|
|
let newSize = Math.max(size * ratio, minSize); |
|
|
undroppableDimension = Math.min(undroppableDimension, maxUndroppableDimension); |
|
|
|
|
|
const newSize = size - undroppableDimension * 2; |
|
|
// Adjust the newSize based on maxUndroppable to prevent exceeding the maximum undroppable area
|
|
|
const newPosition = position + undroppableDimension; |
|
|
newSize = size - Math.min(size - newSize, maxUndroppableDimension); |
|
|
|
|
|
|
|
|
|
|
|
// Calculate the new position by adjusting it by half the reduction
|
|
|
|
|
|
const reduction = size - newSize; |
|
|
|
|
|
const newPosition = position + reduction / 2; |
|
|
|
|
|
|
|
|
|
|
|
return { newSize, newPosition }; |
|
|
return { newSize, newPosition }; |
|
|
} |
|
|
} |
|
|
|