Skip to content

Commit 90e4f16

Browse files
committed
skip elevation graph update when not visible
1 parent fa60eaf commit 90e4f16

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

app/javascript/maplibre/feature/elevation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export async function showElevationChart (feature) {
198198

199199
// Update GPS position indicator on the chart
200200
window.addEventListener('gps-position', (event) => {
201+
if (elevationContainer.offsetParent === null) return
201202
if (!event.detail) {
202203
lastGpsPosition = null
203204
chart._gpsChartIndex = null
@@ -217,6 +218,7 @@ export async function showElevationChart (feature) {
217218

218219
// Sync chart with map viewport — show only the track section currently visible
219220
syncChartToViewport = () => {
221+
if (elevationContainer.offsetParent === null) return
220222
if (!chart.canvas || !chart.canvas.isConnected) {
221223
map.off('moveend', syncChartToViewport)
222224
syncChartToViewport = null

0 commit comments

Comments
 (0)