This commit is contained in:
Nakul Nagargade 2025-03-21 01:44:42 +05:30
parent 4b3f0ed65d
commit f11bea9e3d

View file

@ -44,11 +44,16 @@ const CustomDragLayer = ({ size }) => {
const mainCanvasWidth = document.getElementById('real-canvas')?.offsetWidth || 0;
const width = (mainCanvasWidth * size.width) / NO_OF_GRIDS;
let width = (mainCanvasWidth * size.width) / NO_OF_GRIDS;
// Calculate position relative to the current canvas (parent or child)
const left = currentOffset.x - (canvasBounds?.left || 0);
const top = currentOffset.y - (canvasBounds?.top || 0);
// Adjust position and width if exceeding grid bounds
if (width >= canvasWidth) {
width = canvasWidth;
}
const [x, y] = snapToGrid(canvasWidth, left, top);
return (
<div