Fix: Improve table layout functionality
This commit is contained in:
@@ -151,7 +151,22 @@ const TableConfiguration = () => {
|
||||
{tables.map((table) => (
|
||||
<div
|
||||
key={table.id}
|
||||
className="absolute cursor-pointer hover:scale-110 transition-transform"
|
||||
className="absolute cursor-move hover:scale-110 transition-transform"
|
||||
draggable
|
||||
onDragStart={(e) => {
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
e.dataTransfer.setData('tableId', table.id);
|
||||
}}
|
||||
onDragEnd={(e) => {
|
||||
const rect = e.currentTarget.parentElement?.getBoundingClientRect();
|
||||
if (rect) {
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left - 40, rect.width - 80));
|
||||
const y = Math.max(0, Math.min(e.clientY - rect.top - 40, rect.height - 80));
|
||||
setTables(tables.map(t =>
|
||||
t.id === table.id ? { ...t, position: { x, y } } : t
|
||||
));
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
left: `${table.position.x}px`,
|
||||
top: `${table.position.y}px`
|
||||
|
||||
Reference in New Issue
Block a user