From faf927caa2ecd48d65797e922cd07932f81e5b00 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Sun, 27 Oct 2019 12:14:28 +0100 Subject: [PATCH] save a few cycles when table is hidden --- html/script.js | 52 +++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/html/script.js b/html/script.js index 79d0d32..a5c4532 100644 --- a/html/script.js +++ b/html/script.js @@ -1626,6 +1626,7 @@ function refreshTableInfo() { const topRight = ol.proj.toLonLat([currExtent[2], currExtent[3]]); //console.log([bottomLeft[0], topRight[0]]); //console.log([bottomLeft[1], topRight[1]]); + const sidebarVisible = $("#sidebar_container").is(":visible"); //console.time("updateCells"); for (var i = 0; i < PlanesOrdered.length; ++i) { @@ -1637,28 +1638,32 @@ function refreshTableInfo() { const proj = tableplane.position ? ol.proj.fromLonLat(tableplane.position) : null; //const inView = proj ? ol.extent.containsCoordinate(currExtent, proj) : false; var inView = false; - if (pos && currExtent[2]-currExtent[0] > 40075016) { - // all longtitudes in view, only check latitude - inView = ( - pos[1] > bottomLeft[1] - && pos[1] < topRight[1] - ) - } else if (pos && bottomLeft[0] < topRight[0]) { - // no wraparound: view not crossing 179 to -180 transition line - inView = ( - pos[0] > bottomLeft[0] - && pos[0] < topRight[0] - && pos[1] > bottomLeft[1] - && pos[1] < topRight[1] - ) - } else if (pos && bottomLeft[0] > topRight[0]) { - // wraparound: view crossing 179 to -180 transition line - inView = ( - (pos[0] > bottomLeft[0] - || pos[0] < topRight[0]) - && pos[1] > bottomLeft[1] - && pos[1] < topRight[1] - ) + if (tableInView && sidebarVisible) { + if (pos && currExtent[2]-currExtent[0] > 40075016) { + // all longtitudes in view, only check latitude + inView = ( + pos[1] > bottomLeft[1] + && pos[1] < topRight[1] + ) + } else if (pos && bottomLeft[0] < topRight[0]) { + // no wraparound: view not crossing 179 to -180 transition line + inView = ( + pos[0] > bottomLeft[0] + && pos[0] < topRight[0] + && pos[1] > bottomLeft[1] + && pos[1] < topRight[1] + ) + } else if (pos && bottomLeft[0] > topRight[0]) { + // wraparound: view crossing 179 to -180 transition line + inView = ( + (pos[0] > bottomLeft[0] + || pos[0] < topRight[0]) + && pos[1] > bottomLeft[1] + && pos[1] < topRight[1] + ) + } + } else { + inView = true; } @@ -1675,6 +1680,9 @@ function refreshTableInfo() { ++TrackedAircraftPositions; } + if (!mapIsVisible) + continue + if (tableplane.dataSource == "adsb") { classes += " vPosition"; } else {