added timeout on updateAuto (zoomComplete) to prevent request stacking on mobile phones

This commit is contained in:
l_samenv
2024-08-16 10:42:47 +02:00
parent 9e08f47916
commit 7fa880d67d
2 changed files with 17 additions and 1 deletions

View File

@ -292,6 +292,7 @@ let graphs = (function (){
let created = false;
let activateUpdateTimeout = undefined;
let updateAutoTimeout = undefined;
let container = document.createElement('div');
container.classList.add("graphs-container");
@ -1258,6 +1259,19 @@ let graphs = (function (){
}
}
function onZoomCompleteCallback(){
if (updateAutoTimeout === undefined){
updateAutoTimeout = setTimeout(function() {
updateAuto();
updateAutoTimeout = undefined;
}, 100);
}
else{
clearTimeout(updateAutoTimeout);
updateAutoTimeout = undefined;
}
}
return {
addDataset: addDataset,
//toggleAxesType: toggleAxesType,
@ -1291,6 +1305,7 @@ let graphs = (function (){
shiftNewer: shiftNewer,
jumpToDate: jumpToDate,
initGraphs: initGraphs,
onZoomCompleteCallback:onZoomCompleteCallback,
}
})();
@ -1431,7 +1446,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
sensitivity: 1,
onZoom: function({chart}) { graphs.zoomCallback(chart.graph);},
//onZoomComplete: function({chart}){graphs.checkReload(chart.graph);redraw()},
onZoomComplete: function({chart}){graphs.updateAuto();},
onZoomComplete: function({chart}){graphs.onZoomCompleteCallback()},
}
}
});