feat: add sensor move mode to floor plan
This commit is contained in:
+19
-6
@@ -364,7 +364,7 @@ function renderSensors() {
|
||||
const group = new Konva.Group({
|
||||
id: `sensor-${sensor.id}`,
|
||||
x: absX, y: absY,
|
||||
draggable: mode === 'edit',
|
||||
draggable: mode === 'sensorMove',
|
||||
});
|
||||
|
||||
group.add(new Konva.Circle({
|
||||
@@ -395,8 +395,15 @@ function renderSensors() {
|
||||
listening: false,
|
||||
}));
|
||||
|
||||
group.on('click tap', () => {
|
||||
if (mode === 'view') {
|
||||
notifyFlutter({ type: 'sensorTapped', id: String(sensor.id) });
|
||||
}
|
||||
});
|
||||
|
||||
let pressTimer = null;
|
||||
group.on('mousedown touchstart', () => {
|
||||
if (mode === 'view') return;
|
||||
pressTimer = setTimeout(() => {
|
||||
notifyFlutter({ type: 'sensorTapped', id: String(sensor.id) });
|
||||
pressTimer = null;
|
||||
@@ -544,15 +551,21 @@ window.companion = {
|
||||
|
||||
setMode(newMode) {
|
||||
mode = newMode;
|
||||
const edit = newMode === 'edit';
|
||||
roomsLayer.find('Group').forEach(g => g.draggable(edit));
|
||||
sensorsLayer.find('Group').forEach(g => g.draggable(edit));
|
||||
tagsLayer.visible(!edit);
|
||||
particlesLayer.visible(!edit);
|
||||
roomsLayer.find('Group').forEach(g => g.draggable(newMode === 'edit'));
|
||||
sensorsLayer.find('Group').forEach(g => g.draggable(newMode === 'sensorMove'));
|
||||
tagsLayer.visible(newMode === 'view');
|
||||
particlesLayer.visible(newMode === 'view');
|
||||
_clearDimensions();
|
||||
stage.batchDraw();
|
||||
},
|
||||
|
||||
setRepositioningSensor(id) {
|
||||
sensorsLayer.find('Group').forEach(g => {
|
||||
g.draggable(mode === 'sensorMove' && (id == null || g.id() === `sensor-${id}`));
|
||||
});
|
||||
stage.batchDraw();
|
||||
},
|
||||
|
||||
highlightSensor(id) {
|
||||
sensorsLayer.find('.highlight-ring').forEach(r => r.visible(false));
|
||||
if (id) {
|
||||
|
||||
Reference in New Issue
Block a user