fix(earth): clear lock state when hiding satellites or cables
This commit is contained in:
8
frontend/public/earth/js/controls.js
vendored
8
frontend/public/earth/js/controls.js
vendored
@@ -3,7 +3,7 @@
|
|||||||
import { CONFIG, EARTH_CONFIG } from './constants.js';
|
import { CONFIG, EARTH_CONFIG } from './constants.js';
|
||||||
import { updateZoomDisplay, showStatusMessage } from './ui.js';
|
import { updateZoomDisplay, showStatusMessage } from './ui.js';
|
||||||
import { toggleTerrain } from './earth.js';
|
import { toggleTerrain } from './earth.js';
|
||||||
import { reloadData } from './main.js';
|
import { reloadData, clearLockedObject } from './main.js';
|
||||||
import { toggleSatellites, toggleTrails, getShowSatellites, getSatelliteCount } from './satellites.js';
|
import { toggleSatellites, toggleTrails, getShowSatellites, getSatelliteCount } from './satellites.js';
|
||||||
import { toggleCables, getShowCables } from './cables.js';
|
import { toggleCables, getShowCables } from './cables.js';
|
||||||
|
|
||||||
@@ -228,6 +228,9 @@ function setupTerrainControls() {
|
|||||||
|
|
||||||
document.getElementById('toggle-satellites').addEventListener('click', function() {
|
document.getElementById('toggle-satellites').addEventListener('click', function() {
|
||||||
const showSats = !getShowSatellites();
|
const showSats = !getShowSatellites();
|
||||||
|
if (!showSats) {
|
||||||
|
clearLockedObject();
|
||||||
|
}
|
||||||
toggleSatellites(showSats);
|
toggleSatellites(showSats);
|
||||||
this.classList.toggle('active', showSats);
|
this.classList.toggle('active', showSats);
|
||||||
this.querySelector('.tooltip').textContent = showSats ? '隐藏卫星' : '显示卫星';
|
this.querySelector('.tooltip').textContent = showSats ? '隐藏卫星' : '显示卫星';
|
||||||
@@ -246,6 +249,9 @@ function setupTerrainControls() {
|
|||||||
|
|
||||||
document.getElementById('toggle-cables').addEventListener('click', function() {
|
document.getElementById('toggle-cables').addEventListener('click', function() {
|
||||||
const showCables = !getShowCables();
|
const showCables = !getShowCables();
|
||||||
|
if (!showCables) {
|
||||||
|
clearLockedObject();
|
||||||
|
}
|
||||||
toggleCables(showCables);
|
toggleCables(showCables);
|
||||||
this.classList.toggle('active', showCables);
|
this.classList.toggle('active', showCables);
|
||||||
this.querySelector('.tooltip').textContent = showCables ? '隐藏线缆' : '显示线缆';
|
this.querySelector('.tooltip').textContent = showCables ? '隐藏线缆' : '显示线缆';
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ let lockedObjectType = null;
|
|||||||
let dragStartTime = 0;
|
let dragStartTime = 0;
|
||||||
let isLongDrag = false;
|
let isLongDrag = false;
|
||||||
|
|
||||||
function clearLockedObject() {
|
export function clearLockedObject() {
|
||||||
hoveredCable = null;
|
hoveredCable = null;
|
||||||
hoveredSatellite = null;
|
hoveredSatellite = null;
|
||||||
hoveredSatelliteIndex = null;
|
hoveredSatelliteIndex = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user