From 4542a68f2f6993e84318edcafbe662e1bb4dd0b2 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 15 Jul 2018 15:04:07 -0400 Subject: [PATCH 1/3] Fix y value of tooltip scaling incorrectly Signed-off-by: Mcat12 --- scripts/pi-hole/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index c765b33f..d646bb80 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -99,7 +99,7 @@ var customTooltips = function(tooltip) { } tooltipEl.style.opacity = 1; tooltipEl.style.left = position.left + width + "px"; - tooltipEl.style.top = position.top + tooltip.caretY + "px"; + tooltipEl.style.top = position.top + tooltip.caretY + window.scrollY + "px"; tooltipEl.style.fontFamily = tooltip._bodyFontFamily; tooltipEl.style.fontSize = tooltip.bodyFontSize + "px"; tooltipEl.style.fontStyle = tooltip._bodyFontStyle; From 846e3e4184925d0295fdaa76bc5b0f6385e333df Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 15 Jul 2018 15:04:38 -0400 Subject: [PATCH 2/3] Fix lag by limiting rendering to every 50ms Signed-off-by: Mcat12 --- scripts/pi-hole/js/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index d646bb80..18f1d6aa 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -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) { From dd77a6af5854131a2d04db1a212fe8c0f2eb96e1 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sun, 15 Jul 2018 16:43:14 -0400 Subject: [PATCH 3/3] Add missing semicolon Signed-off-by: Mcat12 --- scripts/pi-hole/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 18f1d6aa..8c28f0bf 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -48,7 +48,7 @@ var customTooltips = function(tooltip) { // 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() + var now = Date.now(); if(now - lastTooltipTime < 50) { return; }