1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/web/ synced 2025-03-09 00:00:01 +01:00

Place new widgets always on top of the existing ones

This commit is contained in:
Ricardo Hernandez-Montoya 2017-04-25 15:41:20 +02:00
parent 1ded5755d8
commit e7660ceace
2 changed files with 14 additions and 1 deletions

View file

@ -19,6 +19,19 @@ const dropzoneTarget = {
position.x -= dropzoneRect.left;
position.y -= dropzoneRect.top;
// Z-Index is one more the top most children
let foundZ = props.children.reduce( (maxZ, currentChildren) => {
// Is there a simpler way? Is not easy to expose a getter in a Container.create(Component)
let widget = currentChildren.props.data;
if (widget && widget.z) {
if (widget.z > maxZ) {
return widget.z;
}
}
return maxZ;
}, 0);
position.z = foundZ >= 100? foundZ : ++foundZ;
props.onDrop(monitor.getItem(), position);
}
};

View file

@ -21,7 +21,7 @@ class WidgetFactory {
height: 100,
x: position.x,
y: position.y,
z: 0
z: position.z
};
// set type specific properties