From d7bc6213434c1c83c5d201007ef025c73ada1698 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:23:52 +0300 Subject: [PATCH 01/33] Fix issue of script non-working for me on Firefox 115 --- JS/fluentRevealNavbar.uc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 1921af6b..bb11c8ad 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -149,7 +149,8 @@ area = el.querySelector(".toolbarbutton-text"); } - if (el.disabled || areaStyle.pointerEvents == "none") { + //if (el.disabled || areaStyle.pointerEvents == "none") { + if (el.disabled) { return this.clearEffect(area); } From 0cc13b78ae717442ebef9c26b5bb91689c00f9c7 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:26:16 +0300 Subject: [PATCH 02/33] Add option to cache nav bar buttons --- JS/fluentRevealNavbar.uc.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index bb11c8ad..a2b8b9d7 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -24,6 +24,9 @@ // whether to show an additional light burst when clicking an element. (not recommended) clickEffect: false, + + // looks for all toolbar buttons only once on script startup — reduces system load, but requires browser restart if toolbar buttons were changed + cacheButtons: true, }; // instantiate the handler for a given window @@ -38,13 +41,15 @@ // get all the toolbar buttons in the navbar, in iterable form get toolbarButtons() { - let buttons = Array.from( - gNavToolbox.querySelectorAll(".toolbarbutton-1") - ); - if (this._options.includeBookmarks) { - buttons = buttons.concat( - Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) + if (!this.buttons || this._options.cacheButtons == false) { + let buttons = Array.from( + gNavToolbox.querySelectorAll(".toolbarbutton-1") ); + if (this._options.includeBookmarks) { + buttons = buttons.concat( + Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) + ); + } } return buttons; } From 0f5df531cf58de389d69822b90bb53d9287dcead Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:27:43 +0300 Subject: [PATCH 03/33] Add option to filter out mouse events too far from navbar --- JS/fluentRevealNavbar.uc.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index a2b8b9d7..af45752a 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -25,6 +25,10 @@ // whether to show an additional light burst when clicking an element. (not recommended) clickEffect: false, + // don't process mouse movements greater than {gradientSize}px from top of the screen, in order to reduce system load + // disable if you modified the ui to have toolbar buttons on different side of the screen (left, right or bottom) + filterDy: true, + // looks for all toolbar buttons only once on script startup — reduces system load, but requires browser restart if toolbar buttons were changed cacheButtons: true, }; @@ -68,6 +72,8 @@ * @param {object} e (event) */ handleEvent(e) { + if (this._options.filterDy && e.clientY > this._options.gradientSize) return; + requestAnimationFrame(time => { switch (e.type) { case "scroll": From e45dba396427afe9ca1ca344fffeefbc3043c293 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:29:50 +0300 Subject: [PATCH 04/33] Added variable to store cached buttons --- JS/fluentRevealNavbar.uc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index af45752a..43731f62 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -33,6 +33,9 @@ cacheButtons: true, }; + // store cached navbar buttons + static buttons; + // instantiate the handler for a given window constructor() { this._options = FluentRevealEffect.options; From 130957ec0375504bd5907b8c4414215c71fb662a Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:30:34 +0300 Subject: [PATCH 05/33] Changed default color to browser navbar button hover --- JS/fluentRevealNavbar.uc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 43731f62..1cd1bbc5 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -17,7 +17,10 @@ includeBookmarks: true, // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) - lightColor: "hsla(224, 100%, 80%, 0.15)", + // lightColor: "hsla(224, 100%, 80%, 0.15)", + + // the color of the gradient. default is the browser's color of navbar button's hover + lightColor: "var(--button-hover-bgcolor)", // how wide the radial gradient is. gradientSize: 50, From 293cc723f1aae1aff204c90bf742b73b155b58d0 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:33:42 +0300 Subject: [PATCH 06/33] Add option to apply the effect to url bar as well --- JS/fluentRevealNavbar.uc.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 1cd1bbc5..45e107a4 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -16,6 +16,9 @@ // if true, show the effect on bookmarks on the toolbar includeBookmarks: true, + // if ture, show the effect on the urlbar as well + includeUrlBar: true, + // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) // lightColor: "hsla(224, 100%, 80%, 0.15)", @@ -52,16 +55,19 @@ // get all the toolbar buttons in the navbar, in iterable form get toolbarButtons() { if (!this.buttons || this._options.cacheButtons == false) { - let buttons = Array.from( + this.buttons = Array.from( gNavToolbox.querySelectorAll(".toolbarbutton-1") ); + if (this._options.includeUrlBar) { + this.buttons.push(gNavToolbox.querySelector("#urlbar-background")); + } if (this._options.includeBookmarks) { - buttons = buttons.concat( + this.buttons = this.buttons.concat( Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) ); } } - return buttons; + return this.buttons; } get placesToolbarItems() { @@ -156,6 +162,8 @@ ? el : el.querySelector(".toolbarbutton-badge-stack") || el.querySelector(".toolbarbutton-icon"); + if (!area) area = el; + let areaStyle = getComputedStyle(area); if ( areaStyle.display == "none" || From 75f9e8d93ad1bc61cdf940d591a3f7295dfe2e04 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:35:03 +0300 Subject: [PATCH 07/33] Remove unused scroll listener --- JS/fluentRevealNavbar.uc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 45e107a4..82392bb3 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -88,7 +88,6 @@ requestAnimationFrame(time => { switch (e.type) { - case "scroll": case "mousemove": if (this._options.clickEffect && this._options.is_pressed) { this.generateEffectsForAll(e, true); From ab69194b453a02ac21a1aad9460e987d46dfc79b Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 22 Jul 2023 20:38:09 +0300 Subject: [PATCH 08/33] Added comment about the change --- JS/fluentRevealNavbar.uc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 82392bb3..82cce77f 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -173,6 +173,7 @@ area = el.querySelector(".toolbarbutton-text"); } + // previous pointerEvents check may break the effect in FF 115 //if (el.disabled || areaStyle.pointerEvents == "none") { if (el.disabled) { return this.clearEffect(area); From a0dec4f3c611d51fdd8682f3f0a05ff7b9010cb2 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 01:10:11 +0300 Subject: [PATCH 09/33] Don't apply effect to focused url bar --- JS/fluentRevealNavbar.uc.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 82cce77f..9c3eb489 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -163,6 +163,11 @@ el.querySelector(".toolbarbutton-icon"); if (!area) area = el; + // don't apply effect to focused url bar + if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { + return this.clearEffect(area); + } + let areaStyle = getComputedStyle(area); if ( areaStyle.display == "none" || From aeceba502c1925e9863ffa653c57490e66cee926 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 01:23:12 +0300 Subject: [PATCH 10/33] Add comment and some padding to make sure effect clears out --- JS/fluentRevealNavbar.uc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 9c3eb489..bd3df9ef 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -84,7 +84,9 @@ * @param {object} e (event) */ handleEvent(e) { - if (this._options.filterDy && e.clientY > this._options.gradientSize) return; + /// filter out mouse events which are too far from toolbar to cause any actual redraw + /// value is {gradientSize} + some additional padding to make sure effect clears out properly + if (this._options.filterDy && e.clientY > this._options.gradientSize + 20) return; requestAnimationFrame(time => { switch (e.type) { From 73c0482ebdd7c7058f037080c7c3af499e459c04 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 01:44:40 +0300 Subject: [PATCH 11/33] Clear all effects once when cursor leaves the interactive zone --- JS/fluentRevealNavbar.uc.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index bd3df9ef..63f07318 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -85,8 +85,11 @@ */ handleEvent(e) { /// filter out mouse events which are too far from toolbar to cause any actual redraw - /// value is {gradientSize} + some additional padding to make sure effect clears out properly - if (this._options.filterDy && e.clientY > this._options.gradientSize + 20) return; + /// value is {gradientSize} + some additional padding to make sure effect fully clears out + if (this._options.filterDy && e.clientY > this._options.gradientSize + 25) { + if (this.someEffectsApplied) this.clearEffectsForAll(); + return; + } requestAnimationFrame(time => { switch (e.type) { @@ -265,6 +268,17 @@ this._options.is_pressed = false; el.style.removeProperty("background-image"); } + + /** + * invoked once when {filterDy} option enabled, and cursor leaves the interactive area + */ + clearEffectsForAll() { + console.log('clear all effects'); + this.someEffectsApplied = false; + this.toolbarButtons.forEach(button => + this.clearEffect(button) + ); + } } function init() { From 77bf366f4eb20c4a3a581c8334f825376e228220 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 01:50:35 +0300 Subject: [PATCH 12/33] Changed cacheButtons default value to prevent unexpected behavior for old users --- JS/fluentRevealNavbar.uc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 63f07318..34cb07c8 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -31,12 +31,12 @@ // whether to show an additional light burst when clicking an element. (not recommended) clickEffect: false, - // don't process mouse movements greater than {gradientSize}px from top of the screen, in order to reduce system load + // don't process mouse movements greater than {gradientSize}px from top of the screen, in order to reduce system load. // disable if you modified the ui to have toolbar buttons on different side of the screen (left, right or bottom) filterDy: true, // looks for all toolbar buttons only once on script startup — reduces system load, but requires browser restart if toolbar buttons were changed - cacheButtons: true, + cacheButtons: false, }; // store cached navbar buttons From 8126494e115dd4272c88ae2bf52495864e555102 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 03:35:48 +0300 Subject: [PATCH 13/33] Bring back "scroll" event listener (as I figured out why it was there) --- JS/fluentRevealNavbar.uc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 34cb07c8..48172658 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -93,6 +93,7 @@ requestAnimationFrame(time => { switch (e.type) { + case "scroll": case "mousemove": if (this._options.clickEffect && this._options.is_pressed) { this.generateEffectsForAll(e, true); From 7af0251e3a3355640093f420ed49b753b36c7b5e Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 07:51:35 +0300 Subject: [PATCH 14/33] Move cached buttons from static to script scope --- JS/fluentRevealNavbar.uc.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 48172658..e2a417b3 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -10,6 +10,9 @@ // ==/UserScript== (function() { + // store cached navbar buttons + let cachedButtons; + class FluentRevealEffect { // user configuration static options = { @@ -39,9 +42,6 @@ cacheButtons: false, }; - // store cached navbar buttons - static buttons; - // instantiate the handler for a given window constructor() { this._options = FluentRevealEffect.options; @@ -54,20 +54,20 @@ // get all the toolbar buttons in the navbar, in iterable form get toolbarButtons() { - if (!this.buttons || this._options.cacheButtons == false) { - this.buttons = Array.from( + if (!cachedButtons || this._options.cacheButtons == false) { + cachedButtons = Array.from( gNavToolbox.querySelectorAll(".toolbarbutton-1") ); if (this._options.includeUrlBar) { - this.buttons.push(gNavToolbox.querySelector("#urlbar-background")); + cachedButtons.push(gNavToolbox.querySelector("#urlbar-background")); } if (this._options.includeBookmarks) { - this.buttons = this.buttons.concat( + cachedButtons = cachedButtons.concat( Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) ); } } - return this.buttons; + return cachedButtons; } get placesToolbarItems() { From 97905a7d2a17d3749a715dca095d4ed2b7839097 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 07:56:00 +0300 Subject: [PATCH 15/33] Remove console log and commented lines --- JS/fluentRevealNavbar.uc.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index e2a417b3..6e39de86 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -25,7 +25,8 @@ // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) // lightColor: "hsla(224, 100%, 80%, 0.15)", - // the color of the gradient. default is the browser's color of navbar button's hover + // the color of the gradient. default is the browser's color on navbar button hover, or a faint baby blue if it's not available. + // you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) lightColor: "var(--button-hover-bgcolor)", // how wide the radial gradient is. @@ -185,7 +186,6 @@ } // previous pointerEvents check may break the effect in FF 115 - //if (el.disabled || areaStyle.pointerEvents == "none") { if (el.disabled) { return this.clearEffect(area); } @@ -274,7 +274,6 @@ * invoked once when {filterDy} option enabled, and cursor leaves the interactive area */ clearEffectsForAll() { - console.log('clear all effects'); this.someEffectsApplied = false; this.toolbarButtons.forEach(button => this.clearEffect(button) From d1091d5cb377b5fbe65107b579f57e36469d8c17 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 07:57:20 +0300 Subject: [PATCH 16/33] Added alternative default color --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 6e39de86..4b55b077 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -27,7 +27,7 @@ // the color of the gradient. default is the browser's color on navbar button hover, or a faint baby blue if it's not available. // you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) - lightColor: "var(--button-hover-bgcolor)", + lightColor: "var(--button-hover-bgcolor, hsla(224, 100%, 80%, 0.15))", // how wide the radial gradient is. gradientSize: 50, From 94dc10c3ebb08f016a520492197c785e33055379 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:04:24 +0300 Subject: [PATCH 17/33] Better selector for url background --- JS/fluentRevealNavbar.uc.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 4b55b077..34cf73a0 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -164,11 +164,10 @@ let { gradientSize, lightColor } = this._options; let isBookmark = el.id === "PlacesChevron" || el.classList.contains("bookmark-item"); - let area = isBookmark + let area = isBookmark || el.id == "urlbar-background" ? el - : el.querySelector(".toolbarbutton-badge-stack") || - el.querySelector(".toolbarbutton-icon"); - if (!area) area = el; + : el.querySelector(".toolbarbutton-badge-stack") || + el.querySelector(".toolbarbutton-icon"); // don't apply effect to focused url bar if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { From 2179e71bfdcb1f9674ccadac0ad45e019b2fdb65 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:21:03 +0300 Subject: [PATCH 18/33] Change area selector for url bar --- JS/fluentRevealNavbar.uc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 34cf73a0..48b0cf8b 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -164,10 +164,11 @@ let { gradientSize, lightColor } = this._options; let isBookmark = el.id === "PlacesChevron" || el.classList.contains("bookmark-item"); - let area = isBookmark || el.id == "urlbar-background" + let area = isBookmark ? el : el.querySelector(".toolbarbutton-badge-stack") || el.querySelector(".toolbarbutton-icon"); + if (!area && el.id == "urlbar-background") area = el; // don't apply effect to focused url bar if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { From 4586237cc189a06bf2c483dfbf0b4ae91b312088 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:23:11 +0300 Subject: [PATCH 19/33] Fixed comment --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 48b0cf8b..2ce89229 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -19,7 +19,7 @@ // if true, show the effect on bookmarks on the toolbar includeBookmarks: true, - // if ture, show the effect on the urlbar as well + // if true, show the effect on the urlbar includeUrlBar: true, // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) From a2cfeb5628155cf30bf52fdef886438167ad4388 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:31:21 +0300 Subject: [PATCH 20/33] Fix for bookmarks --- JS/fluentRevealNavbar.uc.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 2ce89229..a3697533 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -64,7 +64,11 @@ } if (this._options.includeBookmarks) { cachedButtons = cachedButtons.concat( - Array.from(this.placesToolbarItems.querySelectorAll(".bookmark-item")) + Array.from( + personalToolbar().querySelectorAll( + ".toolbarbutton-1, .bookmark-item" + ) + ) ); } } @@ -80,6 +84,13 @@ ); } + get personalToolbar() { + return ( + this._personalToolbar || + (this._personalToolbar = document.getElementById("PersonalToolbar")) + ); + } + /** * main event handler. handles all the mouse behavior. * @param {object} e (event) From 0c82178c32982fb13c392de54c39268575426403 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:33:51 +0300 Subject: [PATCH 21/33] Changed pointer events check to use getComputedStyle(el) --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index a3697533..6c8238eb 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -197,7 +197,7 @@ } // previous pointerEvents check may break the effect in FF 115 - if (el.disabled) { + if (el.disabled || getComputedStyle(el).pointerEvents == "none") { return this.clearEffect(area); } From af6d576e4accb4dea058abba759658ded3162102 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 23 Jul 2023 08:36:09 +0300 Subject: [PATCH 22/33] Use this._toolbarButtons for storing cached buttons --- JS/fluentRevealNavbar.uc.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 6c8238eb..651addb7 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -10,9 +10,6 @@ // ==/UserScript== (function() { - // store cached navbar buttons - let cachedButtons; - class FluentRevealEffect { // user configuration static options = { @@ -55,15 +52,15 @@ // get all the toolbar buttons in the navbar, in iterable form get toolbarButtons() { - if (!cachedButtons || this._options.cacheButtons == false) { - cachedButtons = Array.from( + if (!this._toolbarButtons || this._options.cacheButtons == false) { + this._toolbarButtons = Array.from( gNavToolbox.querySelectorAll(".toolbarbutton-1") ); if (this._options.includeUrlBar) { - cachedButtons.push(gNavToolbox.querySelector("#urlbar-background")); + this._toolbarButtons.push(gNavToolbox.querySelector("#urlbar-background")); } if (this._options.includeBookmarks) { - cachedButtons = cachedButtons.concat( + this._toolbarButtons = this._toolbarButtons.concat( Array.from( personalToolbar().querySelectorAll( ".toolbarbutton-1, .bookmark-item" @@ -72,7 +69,7 @@ ); } } - return cachedButtons; + return this._toolbarButtons; } get placesToolbarItems() { From 96f3ba29499df0fd7c7d320d5e262009fdbc5d20 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Jul 2023 01:40:01 +0300 Subject: [PATCH 23/33] Change static padding to dynamic + cache browser element --- JS/fluentRevealNavbar.uc.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 651addb7..35963be8 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -88,6 +88,13 @@ ); } + get browser() { + return ( + this._browser || + (this._browser = document.getElementById("browser")) + ); + } + /** * main event handler. handles all the mouse behavior. * @param {object} e (event) @@ -95,8 +102,13 @@ handleEvent(e) { /// filter out mouse events which are too far from toolbar to cause any actual redraw /// value is {gradientSize} + some additional padding to make sure effect fully clears out - if (this._options.filterDy && e.clientY > this._options.gradientSize + 25) { - if (this.someEffectsApplied) this.clearEffectsForAll(); + if ( + this._options.filterDy && + e.clientY > + this.browser.getBoundingClientRect().y + + this._options.gradientSize + ) { + if (this._someEffectsApplied) this.clearEffectsForAll(); return; } @@ -225,6 +237,7 @@ * @param {boolean} click (whether the left mouse button is down) */ generateEffectsForAll(e, click = false) { + this._someEffectsApplied = true; this.toolbarButtons.forEach(button => this.generateToolbarButtonEffect(button, e, click) ); @@ -282,7 +295,7 @@ * invoked once when {filterDy} option enabled, and cursor leaves the interactive area */ clearEffectsForAll() { - this.someEffectsApplied = false; + this._someEffectsApplied = false; this.toolbarButtons.forEach(button => this.clearEffect(button) ); From 4cf3620e381e9567d82844b9febb58532ad0402d Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Jul 2023 01:44:01 +0300 Subject: [PATCH 24/33] Fixed typo --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 35963be8..4f0a1bc3 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -62,7 +62,7 @@ if (this._options.includeBookmarks) { this._toolbarButtons = this._toolbarButtons.concat( Array.from( - personalToolbar().querySelectorAll( + this.personalToolbar.querySelectorAll( ".toolbarbutton-1, .bookmark-item" ) ) From aeb10b2252504d3ec0dea690d6ab50969ea15b7e Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:01:42 +0300 Subject: [PATCH 25/33] Removed old comment --- JS/fluentRevealNavbar.uc.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 4f0a1bc3..988f78d2 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -19,9 +19,6 @@ // if true, show the effect on the urlbar includeUrlBar: true, - // the color of the gradient. default is sort of a faint baby blue. you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) - // lightColor: "hsla(224, 100%, 80%, 0.15)", - // the color of the gradient. default is the browser's color on navbar button hover, or a faint baby blue if it's not available. // you may prefer just white, e.g. hsla(0, 0%, 100%, 0.05) lightColor: "var(--button-hover-bgcolor, hsla(224, 100%, 80%, 0.15))", From cd09975b963b29a52ed1c342aa3b72df97005c69 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:02:17 +0300 Subject: [PATCH 26/33] Changed default "filterDy" value to false --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 988f78d2..8af24a75 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -31,7 +31,7 @@ // don't process mouse movements greater than {gradientSize}px from top of the screen, in order to reduce system load. // disable if you modified the ui to have toolbar buttons on different side of the screen (left, right or bottom) - filterDy: true, + filterDy: false, // looks for all toolbar buttons only once on script startup — reduces system load, but requires browser restart if toolbar buttons were changed cacheButtons: false, From 0c96706b36783bc70ce3b9bf15797981f145bf16 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:05:57 +0300 Subject: [PATCH 27/33] Code cleanup --- JS/fluentRevealNavbar.uc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 8af24a75..f2f7cb1b 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -49,7 +49,7 @@ // get all the toolbar buttons in the navbar, in iterable form get toolbarButtons() { - if (!this._toolbarButtons || this._options.cacheButtons == false) { + if (!this._toolbarButtons || !this._options.cacheButtons) { this._toolbarButtons = Array.from( gNavToolbox.querySelectorAll(".toolbarbutton-1") ); @@ -181,7 +181,7 @@ let { gradientSize, lightColor } = this._options; let isBookmark = el.id === "PlacesChevron" || el.classList.contains("bookmark-item"); - let area = isBookmark + let area = isBookmark ? el : el.querySelector(".toolbarbutton-badge-stack") || el.querySelector(".toolbarbutton-icon"); From 819fd64e2213b5d7b353abb137b0f16dba9ea6a0 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:07:05 +0300 Subject: [PATCH 28/33] Removed "!area" check --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index f2f7cb1b..eeab478c 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -185,7 +185,7 @@ ? el : el.querySelector(".toolbarbutton-badge-stack") || el.querySelector(".toolbarbutton-icon"); - if (!area && el.id == "urlbar-background") area = el; + if (el.id == "urlbar-background") area = el; // don't apply effect to focused url bar if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { From 91c0217acbb862448ed9d52d9316ec02461f53a0 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:08:09 +0300 Subject: [PATCH 29/33] Removed "window." part --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index eeab478c..7645327a 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -188,7 +188,7 @@ if (el.id == "urlbar-background") area = el; // don't apply effect to focused url bar - if (this._options.includeUrlBar && el.id == 'urlbar-background' && window.gURLBar.focused) { + if (this._options.includeUrlBar && el.id == 'urlbar-background' && gURLBar.focused) { return this.clearEffect(area); } From e2aa84f839a803df3e06e63748bc32bea0104ba3 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:08:55 +0300 Subject: [PATCH 30/33] Removed absolete comment --- JS/fluentRevealNavbar.uc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 7645327a..c6a369e2 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -202,7 +202,6 @@ area = el.querySelector(".toolbarbutton-text"); } - // previous pointerEvents check may break the effect in FF 115 if (el.disabled || getComputedStyle(el).pointerEvents == "none") { return this.clearEffect(area); } From 3fafeff79aec02c135876d94b5c9c24acb382906 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:11:03 +0300 Subject: [PATCH 31/33] Moved "this_someEffectsApplied" assignments to the bottom --- JS/fluentRevealNavbar.uc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index c6a369e2..15fcaced 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -233,10 +233,10 @@ * @param {boolean} click (whether the left mouse button is down) */ generateEffectsForAll(e, click = false) { - this._someEffectsApplied = true; this.toolbarButtons.forEach(button => this.generateToolbarButtonEffect(button, e, click) ); + this._someEffectsApplied = true; } /** @@ -291,10 +291,10 @@ * invoked once when {filterDy} option enabled, and cursor leaves the interactive area */ clearEffectsForAll() { - this._someEffectsApplied = false; this.toolbarButtons.forEach(button => this.clearEffect(button) ); + this._someEffectsApplied = false; } } From 36a28147c8d292b444086110b318a94d9048adb6 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:14:25 +0300 Subject: [PATCH 32/33] Removed unused "placesToolbarItems getter" --- JS/fluentRevealNavbar.uc.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 15fcaced..3a7e1989 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -69,15 +69,6 @@ return this._toolbarButtons; } - get placesToolbarItems() { - return ( - this._placesToolbarItems || - (this._placesToolbarItems = document.getElementById( - "PlacesToolbarItems" - )) - ); - } - get personalToolbar() { return ( this._personalToolbar || From 80ac4bb0d29b03dd3aa4ac98d1ce69e65c1c1998 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 26 Jul 2023 02:23:54 +0300 Subject: [PATCH 33/33] Removed extra line on bottom --- JS/fluentRevealNavbar.uc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JS/fluentRevealNavbar.uc.js b/JS/fluentRevealNavbar.uc.js index 3a7e1989..7ec2d076 100644 --- a/JS/fluentRevealNavbar.uc.js +++ b/JS/fluentRevealNavbar.uc.js @@ -311,4 +311,4 @@ "browser-delayed-startup-finished" ); } -})(); +})(); \ No newline at end of file