mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
Fix lag by limiting rendering to every 50ms
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
This commit is contained in:
@@ -29,6 +29,8 @@ function objectToArray(p){
|
||||
return [idx,arr];
|
||||
}
|
||||
|
||||
var lastTooltipTime = 0;
|
||||
|
||||
var customTooltips = function(tooltip) {
|
||||
// Tooltip Element
|
||||
var tooltipEl = document.getElementById("chartjs-tooltip");
|
||||
@@ -43,6 +45,15 @@ var customTooltips = function(tooltip) {
|
||||
tooltipEl.style.opacity = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Limit rendering to once every 50ms. This gives the DOM time to react,
|
||||
// and avoids "lag" caused by not giving the DOM time to reapply CSS.
|
||||
var now = Date.now()
|
||||
if(now - lastTooltipTime < 50) {
|
||||
return;
|
||||
}
|
||||
lastTooltipTime = now;
|
||||
|
||||
// Set caret Position
|
||||
tooltipEl.classList.remove("above", "below", "no-transform");
|
||||
if (tooltip.yAlign) {
|
||||
|
||||
Reference in New Issue
Block a user